Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with Query_Case Statement
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00833950
Message ID:
00834208
Views:
46
Sergey

Here is the whole code, but I changed the query to call a function that returns the count, and now it works.
	select meetingnumber,pacustart,pacuEnd,
	     datediff(mi,pacustart,pacuEnd) as pacuminutes,
	     case
		when isnull(dbo.ctAdmissionType.inOrOut,0)=1 then 1
		   else 0
		end as InCnt,
	     case
		when isnull(dbo.ctAdmissionType.inOrOut,0)=1 then datediff(mi,enteror,exitor)
		   else 0
		end as InMinutes,
	     case
		when isnull(dbo.ctAdmissionType.inOrOut,0)=0 then datediff(mi,enteror,exitor)
		   else 0
		end as OutMinutes,
	     case
		when isnull(dbo.ctAdmissionType.inOrOut,0)=0 then 1
		   else 0
		end as OutCnt,
	     case 
		when isnull(dbo.ctAdmissionType.inOrOut,0) = 0 then dbo.Get_ProcsOnCase(meetings.meetingnumber)
		   else 0
                end as ProcOutCount,
             case
		when isnull(dbo.ctAdmissionType.inOrOut,0) = 1 then dbo.Get_ProcsOnCase(meetings.Meetingnumber)
	           else 0
		end as ProcInCount,
		meetings.AnesStart,
		meetings.AnesEnd,
		datediff(mi,meetings.AnesStart,meetings.AnesEnd) as AnesMinutes,
		meetings.AnestID

	from  meetings inner join
		ctAdmissionType on meetings.AdmitTypeID=ctAdmissionType.AdmitTypeID
	where begintime between ?ltQueryFrom and ?ltQueryTo
	and   meetings.iscompleted=1
	and   meetings.isCancelled=0
	and   meetings.deptid=?lnDeptID
	order by pacustart
Previous
Reply
Map
View

Click here to load this message in the networking platform