I want to delete records which don't lie between MIN and MAX from another (nullable) column in the table.
Here is the sql fiddle to build schema and sample data:
http://www.sqlfiddle.com/#!3/14686
I have been trying something like this (which ofcourse doesn't work):
DELETE FROM MeterReadings
WHERE ScheduledReadingDate NOT BETWEEN MIN(ActualReadingDate) and MAX(ActualReadingDate)
GROUP BY MeterId
How do I achieve this?