SQL - SELECT MAX() and accompanying field

后端 未结 4 647
终归单人心
终归单人心 2020-12-31 23:41

What I have is basically a problem which is easily solved with multiple tables, but I have only a single table to do it.

Consider the following database table

<
4条回答
  •  旧时难觅i
    2021-01-01 00:07

    select distinct * from table t1
    where EmailAddress = 
    (select max(EmailAddress) from table t2
    where t1.userId = t2.userId)
    

提交回复
热议问题