I am sure there must be a relatively straightforward way to do this, but it is escaping me at the moment. Suppose I have a SQL table like this:
+-----+-----
SELECT A,B,COUNT(*) FROM table GROUP BY A,B