here's your problem --
Code:
WHERE c.CalibrationDate = ANY
( SELECT MAX(c.CalibrationDate)
FROM calibrationdata c
GROUP BY c.ID )
this subquery returns a whole bunch of dates -- one for each c.ID
your outer query then simply matches dates with dates
thus, the row in the outer query is okay as long as it matches ~any~ of these dates, regardless of whether it's for the correct ID
i'm curious what the MAX(CalibrationDate) in the subquery is for, and what the ID means
please tell us the relationships between your tables -- each district can have oinly one devide, each calibration can have only one district, etc. (obviously these aren't right, so i want to see the actual relationships)
you've got a GROUP BY in the outer query, too, and we need to get rid of that as well