Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql with case and between
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00651902
Message ID:
00651941
Vues:
15
Thanks that did it. I removed the case m.between and just went with the case when ...

Thanks again.

Here is the final solution:
SELECT dbo.corooms.roomname,
	count(roomname) as RoomCnt,
	sum(case 
	  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,
	sum(case
	  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,
	sum(case
	  when m.begintime between CONVERT(varchar(15),m.begintime, 110)+' 00:00:00' and  CONVERT(varchar(15), m.begintime, 110)+' 06:59:00' then 1
	  else 0
	end) as ShiftType3


FROM   dbo.meetings m INNER JOIN
       dbo.corooms ON m.roomid = dbo.corooms.roomid INNER JOIN
       dbo.codept ON m.deptid = dbo.codept.deptid
where iscompleted = 1 and m.deptid = 1
group by roomname
order by roomname
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform