title: SQL SERVER 2005 getting average usages for a year split into 30 day periods
body: <p>I have a table "UserId", "Date", "Application" that records the date and time a user used an application I have manged to split it by month into average usage for the past year. However I have been asked to split in on 30 day billing periods instead of months. Can anyone please help in how I can split the data efficently into a table thats shows for each Application and each 30 days the average number of users.</p>
  
  <p>This is the query for splitting by month an application</p>
  
  <pre><code>select Month(UsageLog.[Date]) as [Month], Year(UsageLog.[Date]) as [Year],
  (Count(UsageLog.UserName)/COUNT(Distinct UsageLog.[Date])) as NumUsers,
  UsageLog.Application
  From Licensing.dbo.Table_UsageLog 
  where UsageLog.[Date] &gt; DATEADD(YEAR,-1,GetDate())
  Group By Month(UsageLog.[Date]), Year(UsageLog.[Date]), UsageLog.Application 
  </code></pre>