Files
mip/Schema/v_current_contact_mechanisms.vw
mullenm 843d4688c4 new view - v_current_contact_mechanisms
git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3029 248e525c-4dfb-0310-94bc-949c084e9493
2007-12-19 17:02:57 +00:00

17 lines
635 B
Plaintext

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;