I want to get top 1 record of each group order by device timestamp, so that I can get top 1 record of each device/imei.
SQL
select 
    o.DeviceTimeStamp, o.DeviceImei, o.OTI_A,OTI_T, 
    ts.latitude, ts.longitude 
from 
    Overview o
left join 
    TransformerLocations ts on o.DeviceImei = ts.imei
where 
    ts.latitude is not null
order by 
    o.DeviceTimeStamp desc
Sample data
2020-11-23 01:03:07.000 8673220311024   0   0   23.842163   91.280693
2020-11-23 01:01:06.000 8673220311024   0   0   23.842163   91.280693
2020-11-23 01:00:00.000 8645020301067   0   0   23.841940   91.280306
Expected output:
2020-11-23 01:03:07.000 8673220311024   0   0   23.842163   91.280693
2020-11-23 01:00:00.000 8645020301067   0   0   23.841940   91.280306
 
    