MS SQL date range and average

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Secode
    New Member
    • Jun 2006
    • 1

    MS SQL date range and average

    Hi

    I am very new to SQL so please excuse this if it is a very simple question - I have 5 colunms of data and one of them is a "date" - what would the SQL query be to sort the data into days with the average of the other fields. ie I have per "5 minute" logging going into the data base for fields 1,2,3,4 and field 0 is the date - I am trying to get the averages of fields 1,2,3,4 for the day.

    Any help will be greatly appreciated.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Something like

    SELECT DATE_FORMAT(dat e, ""%Y/%m/%d") AS Day, AVG(Field1), AVG(Field2), AVG(Field3), AVG(Field4) FROM Table GROUP By Day;

    I believe.

    Comment

    Working...