Conditional aggregation in one grouped query
SELECT
SUBSTR(trans_date, 1, 7) AS month,
country,
COUNT(*) AS trans_count,
SUM(CASE WHEN state = 'approved' THEN 1 ELSE 0 END) AS approved_count,
SUM(amount) AS trans_total_amount,
SUM(CASE WHEN state = 'approved' THEN amount ELSE 0 END) AS approved_total_amount
FROM transactions
GROUP BY month, countryThis is the most direct answer. One grouped scan produces both the all-transaction metrics and the approved-only metrics, which is exactly what conditional aggregation is designed for.