Here are some of the t-Sql queries you can use to find duplicate values
1. Using group by and having
select CabTransactions.TransactionId,y.cabid,y.orderid from
(
select min(cabid) as cabid,orderid,action from CabTransactions
group by cabid,orderid,action
having count(transactionid)>1
) as y,CabTransactions where y.cabid=CabTransactions.CabId and y.OrderId=CabTransactions.OrderId
2. Using not in
select * from cabtransactions where transactionid not in
(
select min(transactionid) from cabtransactions group by cabid,orderid
)
Thanks
Ritesh
1. Using group by and having
select CabTransactions.TransactionId,y.cabid,y.orderid from
(
select min(cabid) as cabid,orderid,action from CabTransactions
group by cabid,orderid,action
having count(transactionid)>1
) as y,CabTransactions where y.cabid=CabTransactions.CabId and y.OrderId=CabTransactions.OrderId
2. Using not in
select * from cabtransactions where transactionid not in
(
select min(transactionid) from cabtransactions group by cabid,orderid
)
Thanks
Ritesh
No comments:
Post a Comment
Comments are welcome, Please join me on my Linked In account
http://in.linkedin.com/pub/ritesh-tandon/21/644/33b