sql server 2008 - How to select distinct combinations of 2 rows in sql -


how select distinct combinations of 2 rows.

eg. given following table

col1 col2     b     b     c c     b b     

i want select

col1 col2      b      c c      b 

note using distinct key word not work include last row b,a.

i don't want last row returned because reverse combination (a,b) in set.

select t1.col1,t1.col2 table t1 col2 not in (select t2.col1 table t2 t2.col2 = t1.col1) group t1.col1,t1.col2 

or

select distinct t1.col1, t1.col2 table t1 col2 not in (select t2.col1 table t2 t2.col2 = t1.col1) 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -