用以下查询:
SELECT SeatPref FROM (SELECT SeatPref, COUNT(CustID) AS seat_count FROM Booking
GROUP BY SeatPref) WHERE seat_count = max(seat_count)
我收到以下错误:
每个派生表必须具有自己的别名。
最佳答案
您缺少表别名-
SELECT t1.SeatPref
FROM (SELECT SeatPref, COUNT(CustID) AS seat_count
FROM `Booking`
GROUP BY SeatPref) t1
WHERE t1.seat_count = max(t1.seat_count)