想要提前選擇旅遊日期和網站名稱的總費用超過230,並且該旅遊已超過7人。完整的代碼如下,工會的第一部分工作。sql中存在無效標識符錯誤的子查詢
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,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 > 230
GROUP BY tour_date, site_name;
我仍然有錯誤,
ORA-00904: "TOTAL_COST": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 437 Column: 7
感謝
認爲你忘了把total_cost放到第一個SELECT語句 – krasu
你想完成什麼?內部查詢沒有where子句,因此您沒有按照任何標準加入表。在您的內部查詢之外,字段預留。*,旅遊。*和網站。*不可用。 – jvilhena
想要提前選擇旅遊日期和地點名稱的總費用超過230,並且該旅遊已超過7人。 –