Reputation: 135
The question is the following: How can I group in the table, but showing all the data the last row the group
Query Table
score team stadium date
20 Ajax Arena Stadium '26/Feb/2020'
10 Madrid Santiago Bernabeu '26/Feb/2020'
10 Ajax Arena Stadium '22/Feb/2020'
Expected result
score team stadium date
20 Ajax Arena Stadium '26/Feb/2020'
10 Madrid Santiago Bernabeu '26/Feb/2020'
Regards
Upvotes: 0
Views: 40
Reputation: 3257
Try this
SELECT score, team, stadium, date
FROM (
SELECT
, ROW_NUMBER() OVER(PARTITION BY score, team ORDER BY date DESC) AS rn
FROM yourTable
) tbl
WHERE rn = 1
Upvotes: 1