我正在使用联合,当这样写查询时,
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) > 7
UNION
SELECT tour_date AS "Departure Date", site_name "Site Name"
FROM (
SELECT res_id, (res_partcost +NVL(RES_GEARCOST,0)) AS "total_cost"
FROM reservation) tour, site
WHERE reservation.tour_id = tour.tour_id
AND tour.site_id = site.site_id
AND total_cost > 230
GROUP BY tour_date, site_name;
但它显示错误为
ORA-00904: "TOUR_DATE": invalid identifier
00904. 00000 - “%s:无效标识符” *原因:
*操作:行错误:305 列:10
所以我不知道为什么我现有的专栏有错误。