Skip to content
Advertisement

How to count missing rows in left table after right join?

There are two tables:

Table education_data (list of countries with values by year per measured indicator).

Table indicators (list of all indicators):

I want to find the indicators for which the highest number of countries lack information entirely i.e. max (count of missing indicators by country)

I have solved the problem in excel (by counting blanks in a pivot table by country)

pivot table with count for missing indicators by country

I haven’t figured our yet the SQL query to return the same results.

I am able to return the number of missing indicators for a set country , read query below, but not for all countries.

I have tried with a cross join without success so far.

Advertisement

Answer

You will have to join on the contries as well, otherwise you can not tell if a contry has no entry in education_data at all:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement