Need help with count function

  • Thread starter Thread starter WebRaster
  • Start date Start date
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
 
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
....
 
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
....
 
Back
Top