sql server - SQL - "duplicate" records but with different dates AND within same day -
we having issues online payment gateway system duplicating transaction entries within minutes of each other.
we want create record of these transactions, can analyse , correct them.
single table, follows. shows results 1 card number. prefer return transactions occurred on same day, , preferably within 5 seconds of each other last 2 rows.
txn_authcode card_number cardtype txn_status txn_value entrytimestamp ------------------------------------------------------------------------------- 1491109220 ....0279 visa failed 20.00 2011-06-24 19:49:00 1491109219 ....0279 visa failed 20.00 2012-05-28 22:47:57 1491109218 ....0279 visa failed 20.00 2012-05-28 22:46:39 1491109217 ....0279 visa failed 20.00 2012-05-28 22:46:35 so far, have following, gets duplicate records given card number, not sure how granularize further in order records in same day , preferably within 5 seconds of each other.
select * from( select t1.txn_authcode,t1.txn_status,t1.txn_value,t1.entrytimestamp transactions t1 1=1 , exists (select null transactions t2 t1.card_number = t2.card_number , t1.entrytimestamp <> t2.entrytimestamp , t2.entrytimestamp >= '2012-05-01' , t2.entrytimestamp <= '2012-06-01' --*** , datediff ( day , t1.entrytimestamp , t2.entrytimestamp ) < 1 --(datediff above doesn't work can return single record given card, --but want records have @ least 1 other transaction record on same --day same card) ) , t1.entrytimestamp >= '2012-05-01' , t1.entrytimestamp <= '2012-06-01' )x order card_number,entrytimestamp desc could give me hand please?
... , datediff ( day , t1.entrytimestamp , t2.entrytimestamp ) < 1 , t1.txn_authcode < t2.txn_authcode ... replace commented out part of query above statement , should need.
Comments
Post a Comment