Groups | Blog | Home
all groups > sql server clients > october 2003 >

sql server clients : Parameterised query error



Angeliki
10/30/2003 5:54:38 AM
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]
ELSE 0 END) "3 to < 6 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view]
ELSE 0 END) "6 to < 9 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view]
ELSE 0 END) "9 to < 12 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view]
ELSE 0 END) "12 to < 15 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view]
ELSE 0 END) "15 to < 18 months",
sum(CASE WHEN cast((wl.durwaitmnt/30)as smallint)
[quoted text, click to view]

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 ?

Sue Hoegemeier
10/30/2003 1:31:56 PM
One issue is that you are using both single quotes and
double quotes - try changing to use just single quotes.

-Sue

On Thu, 30 Oct 2003 05:54:38 -0800, "Angeliki"
[quoted text, click to view]
AddThis Social Bookmark Button