Reputation: 461
I have a table with some entries and i need help with an sql command. The Table consists round about 50 entries with 6 columns.
Table: tbl-planung
ID SID STATUS ... ... ...
1 MDT Yes ... ... ...
2 ABC Yes ... ... ...
3 BLA NO ... ... ...
I need a command which counts the total amount of entries in that table
+ the amount of entries with STATUS = Yes
Like:
TOTAL DONE
50 2
But my command returns
TOTAL DONE
50 50
SQL Command
SELECT Count([tbl-planung].Abgeschlossen) AS Total,
Count([tbl-planung].Abgeschlossen) AS Done
FROM [tbl-planung]
WHERE ((([tbl-planung].Abgeschlossen)=Yes));
Upvotes: 0
Views: 1350
Reputation: 25252
Use SUM instead, without WHERE
:
SELECT Count([tbl-planung].*) AS Total,
-Sum([tbl-planung].Abgeschlossen) AS Done
FROM [tbl-planung]
Upvotes: 1
Reputation: 204746
Use a conditional SUM
SELECT Count(Abgeschlossen) AS Total,
sum(iif(Abgeschlossen = Yes, 1, 0)) AS Done
FROM [tbl-planung]
Upvotes: 2