'Count of questions with errors in Metabase using metadata

I am trying to find the number of active questions in metabase that are currently broken/causing errors for each query type (query=question tool, native=sql).

To find the number of active questions of each type I have used

SELECT COUNT(DISTINCT id), query_type
FROM report_card
WHERE archived = 'false'
GROUP BY query_type;

Output:

count query_type
832 native
472 query

When I try to incorporate the error count I get

SELECT COUNT(DISTINCT rc.id) AS rc_id, rc.query_type,
      (CASE WHEN qe.error IS NULL THEN 'false'
       ELSE 'true' END) AS error_found
FROM report_card rc
INNER JOIN query_execution qe ON qe.card_id =rc.id 
WHERE rc.archived = 'false'
GROUP BY error_found, rc.query_type;

Output:

count query_type error_found
707 native false
292 query false
515 native true
209 query true

Why are the two count columns not adding up to the same total?

I have had a look here, https://discourse.metabase.com/t/metabase-metadata-sql/3688/14 but no luck.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source