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 |
|
anchoredwisdom
Starting Member
22 Posts |
Posted - 2012-07-18 : 06:02:41
|
| col1 col2 col3 col4a b c 1a b c 99d e f 4d e f 5I need the rows where col4= 99 and also rows where col4 <>99but if a row have col4 =99 all the other rows with same col1,col2,col3 should not return.In the example row2 should come as col4=99 but row1 does not qualify as col1,col2,col3 are same in a row with col4=99 row3 and row 4 qualifies.I did this with UNION .select * from table where col4=99 UNION select * from table where (col1,col2,col3) not in (select col1,col2,col3 from table where col4 <>99)Can this be done using not exists or exists?Thanks |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-07-18 : 07:43:23
|
| Dupe:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=176882 |
 |
|
|
|
|
|