gosi75
asked on
Dublicated rows by certain critera
I have rows in my Salestable where I want to find duplicated rows with different salesid.
F.ex. There is a transaction where CustomerKey, Quantity, AccountNumber is dublicated in the database.
The only thing that is not the same is the SalesOrderId but to know that there is a dublicated transaction,
the other SalesOrderID with the same CustomerKey, Quantity and Accountnumber are the same, but the transaction
createddatetime is within 5 minutes between those two transactions.
Any Idea how I could write my query to find all SalesOrderId where above criteria is matched?
f.ex.
SalesOrderID Customerkey AccountNumber Quantity CreatedDateTime
5001 250 1100 1350 2015-08-19 09:16:31.000
5002 250 1100 1350 2015-08-19 09:20:01.000
F.ex. There is a transaction where CustomerKey, Quantity, AccountNumber is dublicated in the database.
The only thing that is not the same is the SalesOrderId but to know that there is a dublicated transaction,
the other SalesOrderID with the same CustomerKey, Quantity and Accountnumber are the same, but the transaction
createddatetime is within 5 minutes between those two transactions.
Any Idea how I could write my query to find all SalesOrderId where above criteria is matched?
f.ex.
SalesOrderID Customerkey AccountNumber Quantity CreatedDateTime
5001 250 1100 1350 2015-08-19 09:16:31.000
5002 250 1100 1350 2015-08-19 09:20:01.000
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
gosi75, do you still need help with this question?
You can try this
Open in new window
The above query will tell you about the records having different salesorderid but common customerkey,accountnumber and quantity.
such records will have RN column having value > 1.
Hope this would help you ...