Display from duplicate records

KaramjeetSingh01 :

Consider there is a table which has 2 columns in it, Name and Age, and records like User1, 21, User2 22, User1 22, User3 19, User3 20. As you can see the User1 and User3 has two values for Age, I only want to retrieve the records with last or maximum value of the Age.

GMB :

I only want to retrieve the records with last or maximum value of the Age.

You can use simple aggregation for this:

select name, max(age) age from mytable group by name

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=402123&siteId=1