SELECT *
FROM
(
SELECT mt.transnumber
,LEAD(mt.transnumber, 1, 1) OVER (PARTITION BY TRNTYPE ORDER BY id) next_transnumber
,mt.trntype
,mt.modifiedtimestamp transaction_time
,LEAD(mt.modifiedtimestamp, 1, SYSDATE) OVER (PARTITION BY TRNTYPE ORDER BY id) next_transaction_time
,floor(((LEAD(mt.modifiedtimestamp, 1, SYSDATE) OVER (PARTITION BY TRNTYPE ORDER BY id) - mt.modifiedtimestamp)*24*60*60)/3600) time_diff
FROM mastertxn mt
WHERE trntype = 'TOPUP'
ORDER BY ID
)
WHERE time_diff >= 1
//Output pattern
TRANSNUMBER NEXT_TRANSNUMBER TRNTYPE TRANSACTION_TIME NEXT_TRANSACTION_TIME TIME_DIFF
1244 1360 TOPUP 05.10.2010 23:58:39 07.10.2010 10:48:43 34
1360 1408 TOPUP 07.10.2010 10:48:43 07.10.2010 16:34:55 5
1442 1507 TOPUP 07.10.2010 19:19:33 08.10.2010 11:26:43 16
Friday, May 27, 2011
Transaction related Query to display two immediate transaction time difference
Transaction related Query to display two immediate transaction time difference
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment