Added code to support minute, hour, day, month, and year query averages