Я выполнил UNION в SQL, который использует ту же таблицу для объединения.
select 'High school education < College education' as 'Qualification criteria', sum(distinct a.cases) as 'Total cases'
from mydb.covid_19_info a inner join mydb.social_health_info b on a.fips = b.fips
where high_school_graduation_rate < percent_some_college
union
select 'High school education > College education' as 'Qualification criteria', sum(distinct a.cases) as 'Total cases'
from mydb.covid_19_info a inner join mydb.social_health_info b on a.fips = b.fips
where high_school_graduation_rate > percent_some_college;
Я хотел бы получить запрос MongoDB для того же самого с использованием агрегации.