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 |
|
influent
Constraint Violating Yak Guru
367 Posts |
Posted - 2007-02-07 : 18:16:19
|
| Let's say I have the following two rows:row_id | group_id | program_id | appdate 1 13 5 '1/1/07' 2 13 4 '1/1/08' 3 15 NULL NULL 5 15 6 '1/1/07'How do I get all rows where none of the rows for the group_id has a NULL for program_id? |
|
|
ModemRat
Starting Member
4 Posts |
Posted - 2007-02-07 : 18:24:26
|
| SELECT row_id, group_id, program_id, appdateFROM <table>WHERE program_id is not null |
 |
|
|
influent
Constraint Violating Yak Guru
367 Posts |
Posted - 2007-02-07 : 18:31:22
|
| Actually no, what I'm looking for is something that will return rows 1 and 2 (which are in the same group) and not rows 3 and 5 (which are also in the same group, but a different one than the first two). Your query will return row 5. This would work, but I'm not sure it's the best solution:SELECT row_id, group_id, program_id, appdateFROM <table>WHERE group_id NOT IN (SELECT group_id FROM <table> WHERE program_id IS NULL) |
 |
|
|
ModemRat
Starting Member
4 Posts |
Posted - 2007-02-07 : 18:42:42
|
| Ah, I understand. Hmm yea not sure what else do do besides what you've got there. |
 |
|
|
|
|
|