Trying to find duplicate values in TWO rows and TWO columns - SQL Server -
using sql server, i'm not dba can write general sql. been pulling hair out hour now. searching i've found several solutions fail due how group works.
i have table 2 columns i'm trying check duplicates:
- userid
- orderdate
i'm looking rows have both userid
, orderdate
duplicates. want display these rows.
if use group by, can't pull other data, such order id, because it's not in group clause.
you use grouped query in subquery:
select * mytable exists (select userid, orderdate mytable b a.userid = b.userid , a.orderdate = b.orderdate group userid, orderdate having count(*) > 1)
Comments
Post a Comment