可以使用 DENSE_RANK
window function.
SELECT *
FROM (
SELECT *,DENSE_RANK() OVER(PARTITION BY [季] ORDER BY [修改版次] DESC) rn
FROM T
WHERE buy IS NOT NULL
) t1
WHERE rn = 1
SELECT 季,MAX(修改版次),BUY,MAX(price)
FROM Table 1
GROUP BY 季,BUY