Hello.
I am trying to run the following query:
select t.orgname,s.descr,
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
<= 3 THEN 1 ELSE 0 END) "0 to < 3 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view] > 3 AND cast((wl.durwaitmnt/30)as smallint) <= 6 THEN 1
ELSE 0 END) "3 to < 6 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view] > 6 AND cast((wl.durwaitmnt/30)as smallint) <= 9 THEN 1
ELSE 0 END) "6 to < 9 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view] > 9 AND cast((wl.durwaitmnt/30)as smallint) <= 12 THEN 1
ELSE 0 END) "9 to < 12 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view] > 12 AND cast((wl.durwaitmnt/30)as smallint) <= 15 THEN 1
ELSE 0 END) "12 to < 15 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view] > 15 AND cast((wl.durwaitmnt/30)as smallint) <= 18 THEN 1
ELSE 0 END) "15 to < 18 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view] > 18 THEN 1 ELSE 0 END) "> 18 months"
from view_pct_all_combined_inpatient_waiting_list_0304 wl
left join trust t
on wl.provcode = t.orgcode
left join spectab s
on wl.specfunc = s.spec
where wl.korner=1
and MONTH(wl.datlistcen) = ?
and pctcode = '5HK'
group by t.orgname,s.descr
order by t.orgname,s.descr
where I would like a prompt to appear, where the user
would have to put the month number. However, I get the
following error:
[Microsoft][ODBC SQL Server Driver]COUNT field incorrect
or syntax error
Does anybody know whay it is happenning and how can I make
this query able to accept the month as a parameter from
the user ?