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 |
|
tadhg88
Yak Posting Veteran
62 Posts |
Posted - 2007-07-24 : 09:57:43
|
| Hi i am trying to write a statement to get the players in a squad based on the StartDate, EndDate of any season and the DateEntered, DateLeft a squad the possible situations are Player joins squad after StartDate and is still there (DateLeft Null)Player joins squad after StartDate and leaves before EndDatePlayer joins before StartDate and is still there (DateLeft Null)Player joins before StartDate and leaves before EndDate this is my statement at the moment but i am gettin players that are in the squad this season and last season sp if anyone has any ideas i would really appreciate them select spm.SquadId,Person.Id as ID, IsNull(firstName+ ' ','') + IsNull(MiddleName+ ' ','') + IsNull(LastName,'') as Name, spm.DateEntered, spm.DateLeftFrom Person LEFT JOIN SquadPlayerMapping spm on spm.PlayerId = Person.IdWhere spm.SquadId = 2927 And ((spm.DateLeft IS NULL) Or (spm.DateEntered >= (Select StartDate From Seasons Where ID = 50))) And spm.DateEntered <= (Select EndDate From Seasons Where ID = 50) Order by LastName thanks in advance Tim |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-07-24 : 11:24:33
|
| You didn't explain very well what it is you are trying to do and what is wrong with your query.It would be helpful if you also provided table structures, sample data, and your expected output.CODO ERGO SUM |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|
|