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 MyTable GROUP BY A, B