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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -