仍然在这里学习 SQL ......我有一个子查询的一部分:
(Select MAX(cost) AS Cost_of_Car FROM Car_Purchase)
但它不带我的标签只是使用表中的一个,在这种情况下是“成本”
有任何想法吗?
编辑:刚刚意识到我可以在我的 SELECT 语句中调用“列名”,但是为什么它在子查询中不接受 AS?
发布完整的查询
SELECT CAR.name, Car_Purchase.cost_per_night, Car_Purchase.description
FROM Car_Purchase
JOIN CAR ON Car_Purchase.purchase_id = CAR.purchase_id
GROUP BY CAR.name, Car_Purchase.cost_per_night, Car_Purchase.description
HAVING Car_Purchase.cost = (SELECT MAX(cost) AS Cost_of_Car FROM Car_Purchase)