Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql with case and between
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00651902
Message ID:
00651909
Views:
16
First, remove 'm.begintime' between CASE and WHEN
... case when m.begintime between ...
Second, tell us what the problem is.

>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
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform