Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
medtech26
Posting Yak Master
169 Posts |
Posted - 2008-03-18 : 17:24:39
|
| Hello,You probably seen this Q before but I have no idea what to search and and therefor any direction would be appreciated.I have three columns table, two are int and one is datetime (for sorting). I would like to query all values witch are unique within the two integers, however, in some cases data looks like this:int1 = 1int2 = 2and another record like:int1 = 2int2 = 1this pair should be considered as a duplicate and second record should not come with the results set.Any suggestions? |
|
|
boesman
Starting Member
1 Post |
Posted - 2008-03-18 : 20:15:27
|
| Assuming your table is tb1 and has the two int columns t1 and t2, use:SELECT DISTINCT CASE WHEN t1 < t2 THEN t1 ELSE t2 END AS tt1, CASE WHEN t1 < t2 THEN t2 ELSE t1 END AS tt2FROM tb1 |
 |
|
|
|
|
|