Is there any SQL query for sort latest date and time from the database. Example below

Output:

Is there any SQL query for sort latest date and time from the database. Example below

Output:

You can use SQL window functions to order and mark records by partition. So using the row_number function you can mark the first row by date as row number 1 and then filter for that.
select [Device name], [Reporting Time], [Unique Id]
from (select *,
row_number()
over (partition by [Device name]
order by [Reporting Time] asc) as [row number]
from [Your Table Name]
) as a
where a.[row number] = 1