Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

get first match in each group mysql query

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;
Source by learnsql.com #
 
PREVIOUS NEXT
Tagged: #match #group #mysql #query
ADD COMMENT
Topic
Name
9+8 =