Forum Moderators: open

Message Too Old, No Replies

Need a SQL Statement

multiple GROUP BY's?

         

mattglet

9:22 pm on Mar 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm racking my brains over getting this statement right, but have not come to a solution (using SQL Server 2000, ASP).

I have 1 table tracking page referrals:

idUser ¦ sReferer ¦ datestamp
-----------------------------
312 ¦msn.com ¦ 3/23/2004
317 ¦yahoo.com ¦ 3/22/2004
312 ¦google.com¦ 3/22/2004

I'm trting to get a count of how many hits per day the user is getting (maybe even hits per day, per referrer?). idUser is of type int, sReferer is of type nvarchar, datestamp is of type datetime. Any ideas?

-Matt

duckhunter

11:15 pm on Mar 23, 2004 (gmt 0)

10+ Year Member



This should do it:

Select datestamp, sReferer, count(*) as 'Hits' from MyTable Group by datestamp, sReferer order by datestamp, sReferer

I run these same queries and graph the data in Excel so I can see referrer traffic across timeperiods.

mattglet

1:11 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



duckhunter-

Your statement worked fine, although I'm trying to first at least get how many hits per day the user is getting. If I can establish that, then I'll look to making it more complex by figuring out user's hits per day, per referrer (be able to drill down results). Hopefully that makes sense...

-Matt