get only last row in each day's multiple entries in TSQL

后端 未结 4 1234
轮回少年
轮回少年 2020-12-31 23:44

I have a table, something like:

Id        Name        EnteredOn                    Percentage
`````````````````````````````````````````````````````````````
         


        
4条回答
  •  -上瘾入骨i
    2021-01-01 00:11

    ;with cte as
    (
      select
        *,
        row_number() over(partition by datediff(d, 0, EnteredOn) order by EnteredOn desc) as rn 
      from YourTable
    )
    select *
    from cte  
    where rn = 1
    

提交回复
热议问题