Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chaaru_akilan
Starting Member
16 Posts |
Posted - 2013-07-05 : 03:57:47
|
Hi I have a table as below,UserID Date Usage1 22/03/2013 97.991 22/03/2014 83.991 23/03/2013 75.991 23/03/2013 81.992 25/03/2013 66.992 25/03/2013 66.992 26/03/2013 55.99I need to calculate the average usage for a user per day.Output would be:UserID Date Usage1 22/03/2013 90.991 23/03/2013 78.99I have got the distinct dates but am not able to iterate through the dates.Please help!Thanks. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-05 : 04:06:16
|
[code]SELECT UserID,[Date],AVG(Usage) AS AvgUsageFROM TableGROUP BY UserID,[Date]ORDER BY UserID,[Date][/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|