July 11, 2017 at 8:47 am
I have the following values in table1
Id, startdate, endDate, PersonID, systemID
1, '01/01/2012', '01/12/2015' 1, 1
2 '01/01/2016, null 1, 2
I need to find the systemId for the startdate '01/10/2017' . It should return the second row
Select systemID from Table1 where @date is between startdate and enddate is retruning Null .
--@date is the input parameter
July 11, 2017 at 8:51 am
Guras - Tuesday, July 11, 2017 8:47 AMI have the following values in table1Id, startdate, endDate, PersonID, systemID
1, '01/01/2012', '01/12/2015' 1, 1
2 '01/01/2016, null 1, 2I need to find the systemId for the startdate '01/10/2017' . It should return the second row
Select systemID from Table1 where @date is between startdate and enddate is retruning Null .
--@date is the input parameter
You've been here long enough to know how the sample data is needed.
July 11, 2017 at 8:53 am
Guras - Tuesday, July 11, 2017 8:47 AMI have the following values in table1Id, startdate, endDate, PersonID, systemID
1, '01/01/2012', '01/12/2015' 1, 1
2 '01/01/2016, null 1, 2I need to find the systemId for the startdate '01/10/2017' . It should return the second row
Select systemID from Table1 where @date is between startdate and enddate is retruning Null .
--@date is the input parameter
-- NULL isn't equal to, not equal to, greater than, or less than, anything else.
-- It's unknown.
SELECT systemID
FROM Table1
WHERE @date >= startdate
AND (@date <= enddate OR enddate IS NULL)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply