title: SQL Query Clarification
body: <p>I have two tables doctor and billing. I wish to view the dname,doctorid and sum(fees) of doctors treating more than one patient.</p>
  
  <p>doctor table columns are as follows:</p>
  
  <pre><code>doctorid,dname
  </code></pre>
  
  <p>billing table columns are as follows:</p>
  
  <pre><code>billid,patientid,doctorid,fees
  </code></pre>
  
  <p>I tried the following code. But got an error stating SQL cmd not properly ended:</p>
  
  <pre><code>SELECT d.dname,b.doctorid,Sum(b.fees)as "TotalFees" FROM billing b,doctor d ON b.doctorid=d.doctorid
  GROUP BY b.doctorid HAVING count(b.patientid)&gt;1; 
  </code></pre>
  
  <p>where have i gone wrong with the syntax?
  Thanks...</p>