Reputation: 2079
With the following query:
SELECT SeatPref FROM (SELECT SeatPref, COUNT(CustID) AS seat_count FROM Booking
GROUP BY SeatPref) WHERE seat_count = max(seat_count)
I am getting the following error:
Every derived table must have its own alias.
Upvotes: 0
Views: 61
Reputation: 5999
You Should add an alias to the subquery (SELECT SeatPref, COUNT(CustID) AS seat_count FROM Booking GROUP BY SeatPref)
.
:)
Upvotes: 1
Reputation: 55489
You are missing table alias -
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)
Upvotes: 6