New answers tagged sorting
2
If there is a foreign key from dw_fact_program_attendance(criteria_id) that REFERENCES dw_dimension_criteria(id), there is no need to join the two tables (but the optimizer is not yet smart enough to understand that.) You can have only one table and GROUP BY criteria_id:
SELECT
a.criteria_id AS c0,
COUNT(DISTINCT a.client_id) AS m0
FROM
...
Top 50 recent answers are included