Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql server daily average

What's the best way to get a daily average. The data would have 2 values per day, for example:

Date             Value
1/1/2012 4:00    10.00
1/1/2012 16:00   11.00
1/2/2012 4:00    11.22
1/2/2012 16:00   13.55
etc.
like image 309
Frank Avatar asked Mar 15 '12 12:03

Frank


Video Answer


2 Answers

Select CAST(DateColumn as date), AVG(Value)
From Table
Group By CAST(DateColumn as date)
like image 145
Abdul Ahad Avatar answered Oct 10 '22 07:10

Abdul Ahad


select date, avg(value)
from yourTable
group by date
like image 44
Diego Avatar answered Oct 10 '22 05:10

Diego