hive sql find the latest record

后端 未结 8 1993
别那么骄傲
别那么骄傲 2021-01-30 17:28

the table is:

create table test (
id string,
name string,
age string,
modified string)

data like this:

id    name   age  modife         


        
8条回答
  •  走了就别回头了
    2021-01-30 18:04

    Give this a try:

    select t1.* from test t1
    join (
      select id, max(modifed) maxModified from test
      group by id
    ) s
    on t1.id = s.id and t1.modifed = s.maxModified
    

    Fiddle here.

    Left outer join solution here.

    Let us know which one runs faster :)

提交回复
热议问题