0

How can i select the latest records from a table for each invidual equipment thats due calibration within 14

Equipment_id | Date_of_last_Calibration | Calibration_Cycle | Calibration_Due_Date
test 10/02/2011 Annual 10/02/2012
test 10/02/2010 Annual 10/02/2011
test2 10/10/2011 Annual 10/10/2013
test3 08/02/2010 Annual 08/02/2011


I can select all records for calibration due within 14 days using

SELECT * FROM equipment_calibration WHERE `Calibration_Due_Date`<= ADDDATE(CURDATE(), INTERVAL 14 DAY)

but i cant limit it to display the latest records only ie

i want it to show that Equipment_id "test" that is due calibration in next 14 days but not the "test" that was last due calibration on a year ago, that was then calibrated

SHOW THIS
test 10/02/2011 Annual 10/02/2012
HIDE THIS
test 10/02/2010 Annual 10/02/2011

Edited by JukesK: spelling mistake

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by baig772
0

Try

SELECT *, MAX(Calibration_Due_Date) FROM equipment_calibration WHERE `Calibration_Due_Date`<= ADDDATE(CURDATE(), INTERVAL 14 DAY)

Edited by baig772: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.