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 |
|
Freddie
Starting Member
29 Posts |
Posted - 2008-11-18 : 12:14:28
|
| Hello:I would like to SELECT * from table WHERE a.date = b.date and status = 'A'but if a.date = b.date and status 'A' doesn't exist i want status 'P'.Is there a function for this?a_date b_date status2008-07-27 00:00:00 2008-07-27 00:00:00 A2008-07-27 00:00:00 2008-08-27 00:00:00 P 2008-06-27 00:00:00 2008-06-27 00:00:00 PThank YouF. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-18 : 12:17:55
|
| [code]SELECT a_date,b_date,MIN(status) AS status from table WHERE a_date = b_date and (status = 'A' or status='P') GROUP BY a_date,b_date[/code] |
 |
|
|
Freddie
Starting Member
29 Posts |
Posted - 2008-11-18 : 12:23:21
|
| Works Great...Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-18 : 12:24:35
|
cheers |
 |
|
|
|
|
|