Walcommon Posted October 7, 2014 Report Posted October 7, 2014 Requirement: I Need to compare the 1st record dt_tx_date to 2nd record dt_tx_date and also 1st record dt_last_update to 2nd record dt_last_update. If both matches Display the event_id and id_event_stage. Here the id_event is the primary key. id_event_stage has duplicates.. Below select i will use as a cursor in a procedure I need to konw what we can do in begin I have the below Query SELECT e.id_event, e.id_event_stage, e.dt_tx_date, e.dt_last_update, e.txt_event_descr FROM event e, ( SELECT id_event_stage, COUNT (*) FROM event WHERE LOWER (txt_event_descr) LIKE 'stage closed as duplicate to%' AND CD_EVENT_STATUS = 'COMP' AND id_event_stage in ( 28814327, 22455139) GROUP BY id_Event_stage HAVING COUNT (*) > 1) dup WHERE e.id_event_stage = dup.id_event_stage AND e.txt_event_descr LIKE 'Stage Closed as Duplicate to%' ORDER BY e.id_event_stage; Result: ID_EVENT ID_EVENT_STAGE DT_TX_DATE DT_LAST_UPDATE TXT_EVENT_DESCR 45997460 22455139 02/06/2004 18:10:00 02/06/2004 18:10:40 Stage Closed as Duplicate to 22429693 46334383 22455139 03/05/2004 10:05:00 03/05/2004 10:05:06 Stage Closed as Duplicate to 22429693 108971118 28814327 01/14/2013 12:08:00 04/25/2014 00:14:00 Stage Closed as Duplicate to 28807179 108971100 28814327 01/14/2013 12:08:00 04/25/2014 00:14:00 Stage Closed as Duplicate to 28807179
Recommended Posts