I’m using SQLite.
I have a simple table
id flag
1 y
2 y
1 n
2 y
3 n
I need to create a query that should give the number of flagged rows
id No
1 1
2 2
3 0
if I use
SELECT Table1.ID as ID, Count(Table1.id) AS No
FROM Table1
WHERE (((Table1.[flag])=True))
GROUP BY ID;
the GROUP BY will ignore the id=3.
What can I do?
You are almost there: instead of
COUNT, useSUM, and move yourwhereclause inside it as a condition.This should work: