开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜