How to solve the problem in SQL?

Good day!

Please tell me how to solve this problem. I haven't worked with SQL, and Google's method of solving was not able :(

This:
There is a table in which three columns: id, value, date.

Need to display unique rows for the column id with the maximum date. If the dates are the same - to bring the maximum value for this id.

Tell me how to do it? Trying to think of a design with GROUP BY and HAVING, so far without success :(

UPD.: I wrote a query that finds the maximum date for each id:
SELECT id, max(date) as max_date FROM Income GROUP BY id

But now how to set a condition that if more than one id and each id in the same date - need to get the maximum value for this id???
April 3rd 20 at 18:42
2 answers
April 3rd 20 at 18:44
Solution
SELECT Income.id, max_date, MAX(value)
 Income FROM
 INNER JOIN (SELECT id, max(date) as max_date FROM Income GROUP BY id) IM
 ON Income.id = IM.id AND Income.date = max_date
 GROUP BY Income.id, max_date
Thanks for your answer!

Trying to test this SQL in the same table on the SQL-EX, but I see the error "Ambiguous column name id". Now trying to Google why. - Amanda.Mor commented on April 3rd 20 at 18:47
SELECT i.id, max(date), MAX(value)
 FROM Income as i
 INNER JOIN (SELECT id, max(date) as max_date FROM Income GROUP BY id) IM
 ON i.id = IM.id AND i.date = IM.max_date
 GROUP BY i.id IM.max_date


Here, slightly altered your version. Works. Thank you! - Amanda.Mor commented on April 3rd 20 at 18:50
April 3rd 20 at 18:46
Perhaps one of these ways will help
Unfortunately, did not help. :(
But still thanks for trying to help. - Amanda.Mor commented on April 3rd 20 at 18:49

Find more questions by tags SQL