Hi all,
I have a table of readings from different meters. The fields are ReadingID (autonum for each record); MeterID (unique to each meter); MetDate; Reading.
Each meter will have many readings. What I am trying to do is return the last 3 readings for each meter. I have used TOP on the descending date data but can only get the last 3 records overall, not the last 3 for each meter:
SELECT TOP 3 READINGS.MeterID, READINGS.Reading, READINGS.MetDate
FROM READINGS
ORDER BY READINGS.MetDate DESC;
If I then put a where clause in stipulating the Meter, I can get the last 3 for that meter but I need output showing the last 3 readings for meter1, meter2, meter3 etc.
Hope this makes sense. Any suggestions on how this can be done?
Cheers, Nat
I have a table of readings from different meters. The fields are ReadingID (autonum for each record); MeterID (unique to each meter); MetDate; Reading.
Each meter will have many readings. What I am trying to do is return the last 3 readings for each meter. I have used TOP on the descending date data but can only get the last 3 records overall, not the last 3 for each meter:
SELECT TOP 3 READINGS.MeterID, READINGS.Reading, READINGS.MetDate
FROM READINGS
ORDER BY READINGS.MetDate DESC;
If I then put a where clause in stipulating the Meter, I can get the last 3 for that meter but I need output showing the last 3 readings for meter1, meter2, meter3 etc.
Hope this makes sense. Any suggestions on how this can be done?
Cheers, Nat