📜  在每组 mysql 查询中获取第一个匹配项 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:54.348000             🧑  作者: Mango

代码示例1
WITH added_row_number AS (
  SELECT
    *,
    ROW_NUMBER() OVER(PARTITION BY year ORDER BY result DESC) AS row_number
  FROM exam_results
)
SELECT
  *
FROM added_row_number
WHERE row_number = 1;