title: Subquery with invalid identifier error in sql
body: <p>want to select tour date and site names in advance of total cost is more than 230 and that tour has more than 7 persons. the complete code is below, the first part of union works. </p>
  
  <pre><code>SELECT tour_date AS "Departure Date",  site_name "Site Name"
  FROM partres, reservation, tour, site
  WHERE partres.res_id = reservation.res_id
    AND reservation.tour_id = tour.tour_id
    AND tour.site_id = site.site_id
  GROUP BY tour_date, site_name
  HAVING COUNT(part_id) &gt; 7
  
    UNION
  
  SELECT tour_date AS "Departure Date",  site_name "Site Name"
  FROM (
    SELECT res_id,tour_date,site_name, (res_partcost +NVL(RES_GEARCOST,0)) as "total_cost" 
    FROM reservation,site,tour) 
  WHERE  reservation.tour_id = tour.tour_id
    AND tour.site_id = site.site_id
    AND total_cost &gt; 230
  GROUP BY tour_date, site_name;
  </code></pre>
  
  <p>I still got errors as </p>
  
  <pre><code>ORA-00904: "TOTAL_COST": invalid identifier
  00904. 00000 -  "%s: invalid identifier"
  *Cause:    
  *Action:
  Error at Line: 437 Column: 7
  </code></pre>
  
  <p>Thanks</p>