You don't need a correlated subquery: sqlite> select * from tbl; c1 c2 ---------- ---------- 1 a 1 a 1 b 1 a 2 b 2 c 2 a 3 c 3 c sqlite> select c1, max(cnt12) from ...> (select c1, count(*) cnt12 from tbl ...> group by c1, c2) ...> group by c1; c1 max(cnt12) ---------- ---------- 1 3 2 1 3 2
Regards