title: Difficulty understanding this query oracle sql
body: <p>I just want to know the internal execution of this query especially how the values in from subquery are being used </p>
  
  <pre><code>SELECT bu, location FROM 
  ( 
      SELECT DISTINCT bu, hqname, location FROM DOCTOR 
      UNION 
      SELECT DISTINCT bu, hqname, location FROM CHEMIST 
      UNION 
      SELECT DISTINCT bu, hqname, location FROM STOCKIST
  ) 
  GROUP BY bu, location 
  HAVING COUNT (DISTINCT hqname) &gt; 1;
  </code></pre>
  
  <p></p>