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(1) As COUNT_OF FROM YourTable GROUP BY A,B