title: Conditional aggregate with Group By clause
body: <p>I'm trying to do this with HiveQL but I don't know how to do this in SQL neither. Table structure as follows: </p>
  
  <pre>
  id1    id2    category  
  123    abc    1
  123    def    1
  123    def    2
  456    abc    1
  123    abc    1
  123    abc    2
  ...  
  </pre>
  
  <p>I'd like to write a query that outputs: </p>
  
  <pre>
  key           count     category1count    category2count
  123-abc        3               2                 1
  123-def        2               1                 1
  456-abc        1               1                 0
  </pre>
  
  <p>So far I've got this: </p>
  
  <pre><code>SELECT concat( concat(id1,'-'), id2), count(*) , 
  count( SELECT * WHERE buyingcategory = 1 ??? ) , 
  count( SELECT * WHERE buyingcategory = 2 ??? ) 
  FROM table 
  GROUP BY concat( concat(id1,'-'), id2)
  </code></pre>