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 |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-11-07 : 14:33:21
|
i have a table like this :account,bankid,branchid,statusfor example :quote: account,bankid,branchid,status123 2 3 5123 2 3 3123 2 3 1
the all 3 keys : account,bankid,branchid can repeat on themselfs with diffrent statusi want to get a list with all the account,bankid,branchid that dosent contians a certain status at all!for example if i dont want status 5 then in the above case i will get false,but if i wantto check the the above didnt have status 22 i will get TRUE!how do i do this?thnaks in advancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-07 : 14:39:50
|
You don't make sense with your requirement.Eitherselect 1 - sign(count(*))from mytablewhere status = 22 It will return 1 if status is not found or 0 if foundorselect distinct account, bankid, status from mytable where status <> 22 Peter LarssonHelsingborg, Sweden |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-11-07 : 14:43:40
|
| that wasnt what i meantif in my example there is a row with status 5 for a certain account+bankid+branchid and i dont want that!!!then your query isnt good beacuse in that case i dont want to get the certain account,bankid,branchid at all!all the idea that if a certain status does exist and i dont want to be in my account+bankid+branchid but its there then i dont want get the account+bankid+branchid at all!Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-07 : 14:47:14
|
If you learn to write clearer questions, maybe you will get your answer faster?select distinct mt.*from mytable mtleft join ( select account, bankid, branchid from mytable where status = 5 ) q ON q.acocunt = mt.account and q.bankid = mt.bankid and q.branchid = mt.branchidwhere q.account is null Peter LarssonHelsingborg, Sweden |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-11-07 : 15:12:28
|
| your correct PESO sorry for the unclearthnaks for the answer!Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-07 : 15:17:30
|
| In my query above, the first column name after ON should be q.account, and nothing else...Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|