Get Single greatest date for each record I have a list of Devices with a gps data table. I would like to grab the last gps coordinates received for each device in the query.

SELECT g.[TimeStamp], d.DeviceId, p.IsHistorical, g.Latitude, g.Longitude, g.Speed, g.Bearing, g.Fix, g.SatelliteCount, p.MessageTypeId
FROM Obd.Device d
LEFT JOIN obd.Packet p ON p.DeviceId = d.Id
LEFT JOIN obd.GPSData g ON g.PacketId = p.Id
WHERE d.ISDId = 1000 AND (g.Latitude IS NOT NULL OR g.Longitude IS NOT NULL)
Another way is to use window functions, either ROW_NUMBER() or MIN():

WITH
  ct AS
  ( SELECT 
        g.[TimeStamp], d.DeviceId, p.IsHistorical, 
        g.Latitude, g.Longitude, g.Speed, g.Bearing, 
        g.Fix, g.SatelliteCount, p.MessageTypeId,
        rn = ROW_NUMBER() OVER (PARTITION BY d.DeviceID
                                ORDER BY g.[TimeStamp] DESC)
    FROM Obd.Device d
      JOIN obd.Packet p ON p.DeviceId = d.Id
      JOIN obd.GPSData g ON g.PacketId = p.Id
    WHERE d.ISDId = 1000 AND (g.Latitude IS NOT NULL OR g.Longitude IS NOT NULL)
  ) 
SELECT 
    [TimeStamp], DeviceId, IsHistorical, 
    Latitude, Longitude, Speed, Bearing, 
    Fix, SatelliteCount, MessageTypeId
FROM ct
WHERE rn = 1 ;


Irrelevant to the question but the condition on g.Latitude and g.Longitude makes the LEFT joins equivalent to INNER joins.