(sql server 2005)
A person uses their cell phone multiple times per day, and the length of their calls vary.
I am tracking the length of the calls in a table:
Table: Calls [callID, memberID, startTime, duration]
I need to a query to return the average call length for users PER DAY.
Per day means, if a user used the phone 3 times, first time for 5 minutes, second for 10 minutes and the last time for 7 minutes, the calculation is: 5 + 10 + 7 / 3 = ...
Note:
People don't use the phone everyday, so we have to get the latest day's average per person and use this to get the overall average call duration.
we don't want to count anyone twice in the average, so only 1 row per user will go into calculating the average daily call duration.
Update Some clarifications:
I want a overall per day average, based on the per-user per-day average, using the users latest days numbers (since we are only counting a given user ONCE in the query), so it will mean we will be using different days avg. since people might not use the phone each day or on the same day even.