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 |
sridhar3004
Starting Member
34 Posts |
Posted - 2014-08-06 : 00:16:39
|
I have the following dataStartdate EndDate Available2014-07-01 2014-07-05 12014-07-06 2014-07-10 12014-07-11 2014-07-15 02014-07-16 2014-07-20 02014-07-21 2014-07-26 12014-07-27 2014-07-31 1I want a query that will retrieve the start date and end date of all the available timeso for the above data, the first available slot will be 2014-07-01 and 2014-07-10 (this is the start date of first record and end date of second row)rows 3 and 4 is not available and will not be a part of the available slots querythe second available slot will 21 Jul 14 to 31 Jul 2014so only 2 rows will be displayed as an output from the above dataThanksSridhar |
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2014-08-06 : 07:37:45
|
What else do you need to see, it sounds very simple what you are trying at the moment:Select StartDate, EndDateFrom YourTableWhere Available = 1Order By StartDateOr use thisSelect StartDate, EndDate, 'Available Slots' = CaseWhen StartDate = 1OR EndDate = 1Then 'Available'Else 'Not Available'EndFrom YourTableOrder By StartDateWe are the creators of our own reality! |
|
|
|
|
|