Can you please tell me how to select a table from two dates.
For example, there is a table"persons"(see attachment)
Please tell me how from the table, select values ​​from the"name","date1" fields, but include only entries with the maximum date field"date2" in the answer.

That is, the answer should look like this:

DB Example:
test_BDtest.db - Download file

2 Answers 2

Create a subquery with grouping by name and maximum date.Then link to the main table using the"name" and"date2" fields.
select
t1.name,
t1.date1,
t2.date2
from persons t1
join(
	select
	name,
	max(date2) as date2
	from persons
	group by name
) t2 on t2.name=t1.name and t2.date2=t1.date2