Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

ottieni solo l'ultima riga nelle voci multiple di ogni giorno in 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