title: SQL group function for multiple columns?
body: <p>I really need help with this question. </p>
  
  <p>Given an instance of two relations, what is the result of the query? I know the answer, I just need to know how you get it? I'm really confused regarding the <code>GROUP</code> line. </p>
  
  <p>Relation R (A, B):</p>
  
  <pre><code>1  2
  3  4
  1  3
  </code></pre>
  
  <p>Relation S (B, C):</p>
  
  <pre><code>1  3
  2  4
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>SELECT R.A, avg(R.B) as av
  FROM R, S
  WHERE R.B &lt; 4
  GROUP BY R.A, S.C
  HAVING max(S.B) &gt;= 2
  </code></pre>
  
  <p>Answer is: </p>
  
  <pre><code>A   Av
  1   2.5
  </code></pre>