开发者

Building SQL query for a table structure

开发者 https://www.devze.com 2023-02-12 04:27 出处:网络
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.

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

精彩评论

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