title: How to order by count desc in each group in a hive?
body: <p>Here's the HQL:</p>
  
  <pre><code>select A, B, count(*) as cnt from test_table group by A, B order by cnt desc;
  </code></pre>
  
  <p>The sample output is as follows:</p>
  
  <pre><code>a1 | b1 | 5
  a2 | b1 | 3
  a1 | b2 | 2
  a2 | b2 | 1
  </code></pre>
  
  <p>But what I want is to do the <code>order by</code> in each group of A, and the intended output is like:</p>
  
  <pre><code>a1 | b1 | 5
  a1 | b2 | 2
  a2 | b1 | 3
  a2 | b2 | 1
  </code></pre>
  
  <p>Could anyone can give me some idea how to resolve this problem in just <strong>one</strong> HQL? Thanks a lot!</p>