WITH RankedData AS (
SELECT
DATEPART(MONTH, YourDateColumn) AS MonthNumber,
mounthStaffSer,
ROW_NUMBER() OVER (PARTITION BY DATEPART(MONTH, YourDateColumn) ORDER BY mounthStaffSer DESC) AS rn
FROM
YourTableName
WHERE
-- 这里可以添加年份或其他筛选条件,如果需要的话
YourDateColumn BETWEEN '2023-01-01' AND '2023-12-31' -- 假设你要查询2023年的数据
)
SELECT
MonthNumber,
mounthStaffSer
FROM
RankedData
WHERE
rn <= 10 -- 选择每个月最大的10条数据
ORDER BY
MonthNumber, -- 按月份排序
mounthStaffSer DESC; -- 如果需要,可以按mounthStaffSer降序排序