title: SUM and JOIN clause in sql
body: <p>There are 3 tables with respective columns :<br>
  wc_dept   : dept_id,dept_name<br>
  wc_doctor : dept_id,doc_id,doc_name,consult_fee<br>
  wc_patient: doc_id,consult_id,patient_name<br></p>
  
  <p>For the following queries I am getting different results :</p>
  
  <p>Query 1 :</p>
  
  <pre><code>select dept_name,sum(consult_fee)
  from wc_doctor do,wc_dept dp,wc_patient p
  where
  do.dept_cd=dp.dept_cd
  AND
  do.doc_id=p.doc_id
  group by dept_name;
  </code></pre>
  
  <p>The output for the above query is a very large amount of money for every department compared to the actual amount i.e, sum of consultation fee in each department.</p>
  
  <p>Query 2 :</p>
  
  <pre><code>select dept_name,sum(consult_fee)
  from wc_doctor do,wc_dept dp
  where
  do.dept_cd=dp.dept_cd
  group by dept_name;
  </code></pre>
  
  <p>The output of the Query 2 gives the exact sum of consultation fee for each department.</p>
  
  <p><strong>Why is the difference between query1 and query2 ? how is consult_id column behaving in query1?</strong></p>