diff --git a/Schema/mipViews.sql b/Schema/mipViews.sql index 70cf7bd..2f0f98c 100644 --- a/Schema/mipViews.sql +++ b/Schema/mipViews.sql @@ -11,4 +11,5 @@ @@V_HOCO.vw @@V_BACO.vw @@V_AICO.vw -@@V_CURRENT_PARTY_ADDRESSES.vw \ No newline at end of file +@@V_CURRENT_PARTY_ADDRESSES.vw +@@v_current_contact_mechanisms.vw \ No newline at end of file diff --git a/Schema/v_current_contact_mechanisms.vw b/Schema/v_current_contact_mechanisms.vw new file mode 100644 index 0000000..f6f65d5 --- /dev/null +++ b/Schema/v_current_contact_mechanisms.vw @@ -0,0 +1,16 @@ +CREATE OR REPLACE VIEW v_current_contact_mechanisms AS +SELECT * +FROM (SELECT prty.ID AS Prty_ID, + come_id AS Come_ID, + come.comt_code AS Code, + come.contact_value AS Contact_value, + prty_come.start_date AS start_date, + prty_come.end_date AS end_date, + prty_come.comments AS comments, + MAX(prty_come.start_date) over(PARTITION BY prty.ID, come.comt_code) AS max_start_date + FROM parties prty, + party_contact_mechanisms prty_come, + contact_mechanisms come + WHERE prty.id = prty_come.prty_id + AND come.id = prty_come.come_id) +WHERE start_date = max_start_date;