title: How to do SUM based on SELECT DISTINCT on multiple column
body: <p>I have a table where there are 3 numeric columns <code>(a,b,c)</code> and two categorical column <code>(x,y)</code>. I want make a sum for <code>a ,b and c</code> but based on each <strong>unique</strong> <code>x and y</code> combination. How can I do that ?
  I have tried the following code</p>
  
  <pre><code>SELECT   
  SUM(CAST(t.a as INT64)) as a_,
  SUM(CAST(t.b  as INT64)) as b_ ,
  SUM(CAST(t.c  as INT64)) as c_,
  
  FROM (
    SELECT DISTINCT x ,y FROM &lt;table_name&gt;  
  ) t
  </code></pre>
  
  <p>Now what I am getting is <code>a</code> not found insde <code>t</code></p>
  
  <p>How can I fix that ? what I am doing wrong ?</p>