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 |
|
drpkrupa
Yak Posting Veteran
74 Posts |
Posted - 2007-04-13 : 13:08:44
|
| I have a table with three feildID, status , accountno1 2 1002 1 1003 1 2004 1 3005 2 300I need result: all record with status 2 but if they pass next time then exclude.I need result only for accountno 300for 100 it was fail = 2 but it pass later 1 so exclude |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-13 : 13:11:21
|
| what is the 'pass' limit? is it always 100? So anything above 100 is pass?SELECT ..FROM ..WHERE status =2 and accountno > 100************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-13 : 13:15:36
|
| [code]SELECT AccountNoFROM Table1GROUP BY AccountNoHAVING MAX(CASE WHEN Status < 2 THEN ID END) < MAX(CASE WHEN Status >= 2 THEN ID END)[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|