title: SQL syntax error: near "("
body: <p>When I try to run this query:</p>
  
  <pre><code>select branch_no, max (avg_salary)
  from (select allocatedto, avg (salary)
        from staff, worker
        where staff.staff_no = worker.staff_no
        group by allocatedto) 
        as branch_avg (branch_no, avg_salary);
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Error: near "(": syntax error
  </code></pre>