Wednesday, July 31, 2013

finding monthly aggregates on OLTP

I have four different pages within a site. Each page has an ID. Every customer that visits the site has a unique ID. Every visit has a date and time column. Now I want to find the monthly average visits of a particular customer on a particular page. The query below gives the daily count of a particular customers page visit. Now I want the monthly average of the same.



SELECT date, pagetype, customerID, COUNT(customerID)as Number
FROM [dbo].[pageinfo] join [dbo].[customer]
on pageinfo.cid = customer.id
group by date, pagetype, customerID


No comments:

Post a Comment