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 |
|
cwfontan
Yak Posting Veteran
87 Posts |
Posted - 2010-05-19 : 17:58:14
|
| I need to make my query So i need to select all the rows where endDate is NULLif it has an endDate then SElect the MAX for that IDselect *From vwhere startdate < getdate AND(enddate is NULL OR Exists ( select MAX(endDate) as maxEndDate FROM d WHERE d.ID = v.id) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-20 : 09:35:21
|
| select * from vwhere (startdate < getdate() ANDstartdate = (select MAX(endDate) as maxEndDate FROM d WHERE d.ID = v.id) )ORstartdate is nullMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|