Building SQL query for a table structure
For the following table structure Booking Fields - BookingID(Primary key), CustID, SeatPref
I want to get the SeatPref which is preferred by most C开发者_Python百科ustIDs.
Please help.
select
seatpref,
count(seatpref) as PrefCount
from
Bookings b
group by
seatpref
order by
count(seatpref) desc
I think
SELECT SeatPref, count(SeatPref) AS NumCusts
FROM your_table
GROUP_BY SeatPref
ORDER_BY NumCusts
should do it.
精彩评论