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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-09-17 : 08:29:27
|
| Nikhil writes "I have one table with the following fields with the data:PO No Amt Inv Amt Rec Category1 1000 0 Inv1 0 1000 Rec2 1111 0 Inv2 0 1111 Rec3 2222 0 Inv4 0 3333 Rec5 5555 0 InvI want a query which will select PO without category as "Rev". The result of query is as follows:PO No Amt Inv Amt Rec Category3 2222 0 Inv5 5555 0 InvI want the PO with categoryas "Inv" but without "Rev"Thanks & Regards,Nikhil" |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-17 : 08:48:29
|
maybe:select *from MyTablewhere category <> 'Rec'Go with the flow & have fun! Else fight the flow |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-09-17 : 10:09:04
|
| select * from myTablewhere PO in (select POfrom myTablegroup by POhaving max(category) = 'Inv') |
 |
|
|
sahu74
Posting Yak Master
100 Posts |
Posted - 2004-09-17 : 10:30:21
|
This should work. Give it a try.Select * from TblNamewhere [PO No] NOT IN (SELECT [PO No] FROM TblName WHERE Category='Rec') PKS. |
 |
|
|
|
|
|