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 |
|
atompaaa
Starting Member
2 Posts |
Posted - 2010-11-30 : 05:23:10
|
| Hello!I´m making this query into a temporary table, now I want to make the result list a little shorter. Sample of result from the temp table with no where or group or anything:____Artnr | Place | OK or Not99999000055 01010201 Not OK99999000055 01010201 Not OK99999000055 01010201 OK99999000055 01010201 OK99999000055 01010201 OK42037901104 01010203 OK42037901104 01010203 OK _____then it goes on.. What I want is to make a query against the temp table where the result is to only show the "Artnr"´s where "OK or Not" is OK on all its lines. In the result above I would´ve liked it to only show 42037901104 on one line. How can I do this? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-11-30 : 05:29:30
|
select DISTINCT Artnr from table as t1 where [OK or Not] = 'OK'and not exists(select * from table as t2 where t2.Artnr=t1.Artnr and [OK or Not] = 'Not OK') No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
atompaaa
Starting Member
2 Posts |
Posted - 2010-11-30 : 05:47:18
|
| That worked very nice, thank you! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-11-30 : 07:26:56
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|