working min max tempurature chart but slow sql method