Improved SQL query to filter out invalid temperatures