new view - v_current_contact_mechanisms
git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3029 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
16
Schema/v_current_contact_mechanisms.vw
Normal file
16
Schema/v_current_contact_mechanisms.vw
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user