title: Count records of a column after group by in SQL
body: <p>I'm running this query:</p>
  
  <pre><code>SELECT "uname","sip",count(1) as cnt FROM "random_data_date" GROUP BY "uname","sip";
  </code></pre>
  
  <p>To get something like this:</p>
  
  <pre><code>+------------+-----------------+--------------+
  |   uname    |    sip          | cnt          |
  +------------+-----------------+--------------+
  | root       | 172.17.165.60   | 1            |
  | root       | 172.17.53.124   | 2            |
  | root       | 172.28.184.39   | 3            |
  | root       | 192.168.207.7   | 1            |
  | root       | 192.168.245.110 | 1            |
  | user1      | 172.17.165.60   | 1            |
  | user1      | 172.24.85.227   | 10           |
  | user1      | 172.25.14.184   | 2            |
  | user2      | 172.16.194.151  | 1            |
  | user2      | 172.16.248.88   | 1            |
  | user2      | 172.16.9.55     | 1            |
  | user2      | 172.17.165.60   | 2            |
  | user2      | 172.17.234.122  | 1            |
  | user2      | 172.17.53.124   | 1            |
  +------------+-----------------+--------------+
  </code></pre>
  
  <p>Is there a way so that I can make it add up the number of <code>sip</code>s for each username, and add up the <code>cnt</code>s of them, so the output is like this:</p>
  
  <pre><code>+------------+-----------------+--------------+
  |   uname    |    sipcnt       | cnt          |
  +------------+-----------------+--------------+
  | root       | 5               | 8            |
  | user1      | 3               | 13           |
  | user2      | 6               | 7            |
  +------------+-----------------+--------------+
  </code></pre>
  
  <p>I'm using <a href="http://phoenix.apache.org/language/index.html" rel="nofollow noreferrer">Apache Phoenix</a> to query Apache HBase.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/5146978/count-number-of-records-returned-by-group-by">this question</a> that is similar but I don't know how would I apply the answers to my situation.</p>