I have a
Voters table, which has fields including
party takes just a few acceptable values. I have a query which counts party membership and groups by the party:
SELECT party as Party, COUNT(*) AS Party_COUNT
GROUP BY party
ORDER BY Party_COUNT DESC;
Works nicely. I would now like to show additional data: how many of those party members have an email address recorded in the DB?
I should end up with something like the following:
Party Party_COUNT EMail DEM 90802 10000 REP 41383 5000 NPP 40000 4750 ...etc.
I get the aggregate email count easily with:
SELECT COUNT(*) email from Voters WHERE email <> ''
but I'm having trouble mashing my two count queries together to get the desired tabular result.
This is in MariaDB 10.1.18.
I am counting
WHERE email <> '' because I receive the dataset from a governmental agency which can't even provide the DDL for the database, just a CSV dump.
The field seems to have only NULLs or actual e-mail addresses, but I can't be sure, especially as this data is updated somewhat frequently. Furthermore, CSV will not properly reflect NULLS, so empty strings are imported . . .