/* Count the number of ColumnA lines where ColumnB is above 10 */ SELECT COLUMNA , SUM(CASE WHEN COLUMNB > 10 THEN 1 ELSE 0 END) AS COUNT_ABOVE_TEN FROM TABLEA GROUP BY COLUMNA