How can we count employees by condition?
Nesting CASE inside COUNT() computes conditional counts in a single table scan without subqueries.
Pivot-style metric reporting, active vs inactive counts, department breakdown columns.
SELECT
COUNT(CASE WHEN department = 'Engineering' THEN 1 END) AS engineers,
COUNT(CASE WHEN department = 'Analytics' THEN 1 END) AS analysts
FROM employees;Practice typing production-grade SQL code for Conditional Aggregation.