Need help with count function

W

WebRaster

I need to count how much "assenze" I have in this query, as cover is a text
field I try to use the IIF as you can see below. BUT It does work! Damn.

Query = "SELECT Sum(IIF(cover = 'NO', 1, 0)) as assenze, SUM(stato) as
daypresidio FROM copertura WHERE day between '11/12/2005' and '11/18/2005'
Group by day ORDER BY day ASC"

Please Help
 
N

Norman Yuan

Since you post in Access.adp.sqlserver NG, I assume your query is going to
run on Sql Server/MSDE.

There is no IIF... in T-SQL, you use CASE... instead:

SELECT
SUM
(
CASE
WHEN conver='NO' THEN 1
ELSE 0
END
) AS assenze,
SUM(stato) AS daypresido
FROM
....
 
W

WebRaster

Thank you very much.


Norman Yuan said:
Since you post in Access.adp.sqlserver NG, I assume your query is going to
run on Sql Server/MSDE.

There is no IIF... in T-SQL, you use CASE... instead:

SELECT
SUM
(
CASE
WHEN conver='NO' THEN 1
ELSE 0
END
) AS assenze,
SUM(stato) AS daypresido
FROM
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top