Two separate column counts grouped by one of those columns I have a Voters table, which has fields including party and email.

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
FROM Voters
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 &lt;&gt; ''


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 &lt;&gt; '' 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 . . .
To count rows:

COUNT(*)


To count non-null values in a column:

COUNT(email)


To count non-null values, without counting the empty strings:

COUNT(CASE WHEN email &gt; '' THEN email END)    -- or
COUNT(CASE WHEN email &gt; '' THEN 1 END)        -- or
SUM(email &gt; '')                               -- or
COUNT(email) - SUM(email = '')