Here\'s the HQL:
select A, B, count(*) as cnt from test_table group by A, B order by cnt desc;
The sample output is as follows:
select A, B, count(*) as cnt from test_table group by A, B order by A, cnt desc;