Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

obtenha apenas a última linha nas várias entradas de cada dia no TSQL

;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