sql - select only some rows when multiple columns duplicates -


i want select 1 set of rows when have 3 specific columns duplicates. example, in table, want 1 of 2 quotes show copies.

quotenumber|linenumber|billtocustomer|purchaseorder|creationdate|item ...........|..........|..............|.............|............|......... 11         | 1        | john         | 35          | 2014-04-09 | x1234  11         | 2        | john         | 35          | 2014-04-09 | x5678 12         | 1        | john         | 35          | 2014-04-09 | x1234  12         | 2        | john         | 35          | 2014-04-09 | x5678-2 

so have that:

select * vgqesheader qh left join vgqesdetail qd on qh.link = qd.quotelink 

and criteria put:

qd.linenumber='1'   count(qh.billtocustomer)>1  count(qh.purchaseorder)>1  count(qh.creationdate)>1 

and no clue how it.

i tried not doesn't seem work.

edit : expected output:

quotenumber|linenumber|billtocustomer|purchaseorder|creationdate|item ...........|..........|..............|.............|............|......... 11         | 1        | john         | 35          | 2014-04-09 | x1234  11         | 2        | john         | 35          | 2014-04-09 | x5678 

try this:

;with cte (select *, row_number() on (partition linenumber order quotenumber) rn tbl) select quotenumber, linenumber, billtocustomer, purchaseorder, creationdate, item  cte rn = 1 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -