Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql with case and between
Message
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Sql with case and between
Miscellaneous
Thread ID:
00651902
Message ID:
00651902
Views:
52
Below is a sql statement I've been trying to get running. As you can probably guess, it doesn't work. I'm using a between statement in the case clause. Right now I have the times hardcoded for the shifts, but eventually, they will be passed as parameters.
SELECT dbo.corooms.roomname,
	case m.begintime
	  when m.begintime between CONVERT(varchar(15),m.begintime, 110)+' 07:00:00' and CONVERT(varchar(15), m.begintime, 110)+' 14:59:00' then 1
	  else 0
	end as ShiftType1
	case m.begintime
	  when m.begintime between CONVERT(varchar(15),m.begintime, 110)+' 15:00:00' and CONVERT(varchar(15), m.begintime, 110)+' 23:59:00' then 1
	  else 0
	end as ShiftType2

FROM   dbo.meetings m INNER JOIN
       dbo.corooms ON m.roomid = dbo.corooms.roomid INNER JOIN
       dbo.codept ON m.deptid = dbo.codept.deptid
order by roomname
Any help and pointers greatly appreicated
Next
Reply
Map
View

Click here to load this message in the networking platform