I have been given this task for a project – “We have a single table which has the following JOB_ID, TRN_ID, MEMBER_ID, PROVIDER_ID, TRANSACTION_NAME, CREATETIME.
Write an SQL query that Identifies any duplicate transactions that may have occurred if the CTREATETIME is within 15 seconds of another. Only the JOB_ID and TRN_ID should be unique.”
Below is what I came up with. Can someone tell me if this is anywhere close to what I was supposed to do?
”’Select t.*
from DHL_Table t
where exists (
select 1
from DHL_Table t1
where
t1.TRN_ID = t.TRN_ID and t1.JOB_ID = t.JOB_ID
and t1.CREATETIME > dateadd(minute, -15, t.CREATETIME)
and t1.CREATETIME < t.CREATETIME
)”’