Forum Discussion
Off Topic: Need help with SQL Query
- 2 years ago
SELECT
DeviceID,
ModifiedDate,
OBDOdometerMeters,
UTCOBDOdometerMetersDatefrom (
SELECT
DeviceID,
ModifiedDate,
OBDOdometerMeters,
UTCOBDOdometerMetersDate,
ROW_NUMBER() OVER (PARTITION BY DeviceID ORDER BY ModifiedDate DESC , UTCOBDOdometerMetersDate desc ) AS RowNum
FROM
YourTableName
) as aWHERE
RowNum = 1;the previous should work.
however you can try this approach ( using nested selected query ) .
let me know if this helps .
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution ✅
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠
Trying your query now. Getting the following red underlines...so doesn't like something:
Do you know where I am going wrong, or what I might be missing?
SELECT
DeviceID,
ModifiedDate,
OBDOdometerMeters,
UTCOBDOdometerMetersDate
from (
SELECT
DeviceID,
ModifiedDate,
OBDOdometerMeters,
UTCOBDOdometerMetersDate,
ROW_NUMBER() OVER (PARTITION BY DeviceID ORDER BY ModifiedDate DESC , UTCOBDOdometerMetersDate desc ) AS RowNum
FROM
YourTableName
) as a
WHERE
RowNum = 1;
the previous should work.
however you can try this approach ( using nested selected query ) .
let me know if this helps .
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution ✅
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠