For example, in the figure below, sn is s002 and there are three duplicate data. When requesting a query, s002 only takes the one with Id=4
The method is to use group by, use Id as a unique identifier (self-increasing), arrange by sn, and then take the largest Id of duplicate items (non-repeated items directly take the unique Id), thereby filtering out duplicate data.
sql code is
select * from test where Id in (select max(Id) from test group by sn)
The result obtained is: