SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 GROUP BY
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nietzky
Yak Posting Veteran

72 Posts

Posted - 10/17/2013 :  15:05:59  Show Profile  Reply with Quote
I have a table that looks like this:
SID Pages PageViews Visits CheckDate
Peter http://X1.somehostname.net/page1.aspx 4 3 9/2/2013
Peter http://X1.somehostname.net/page2.aspx 1 1 9/2/2013
George http://X1.somehostname.net/page3.aspx 4 4 9/2/2013
George http://X1.somehostname.net/secure/page4.aspx 3 3 9/2/2013
George http://X1.somehostname.net/secure/page5.aspx 2 1 9/2/2013
George http://X1.somehostname.net/page6.aspx 3 3 9/2/2013
George http://X1.somehostname.net/page7.aspx 4 4 9/2/2013
George http://X1.somehostname.net/page8.aspx 1 1 9/2/2013
Albert http://X1.somehostname.net/page1.aspx 1 1 9/2/2013
Albert http://X1.somehostname.net/page3.aspx 0 1 9/2/2013
Albert http://X1.somehostname.net/page21.aspx 1 1 9/2/2013
Albert http://X1.somehostname.net/page17.aspx 1 1 9/2/2013
Peter http://X1.somehostname.net/page1.aspx 4 3 9/9/2013
Peter http://X1.somehostname.net/page2.aspx 1 1 9/9/2013
George http://X1.somehostname.net/page3.aspx 15 15 9/16/2013
George http://X1.somehostname.net/secure/page4.aspx 102 17 9/16/2013
George http://X1.somehostname.net/secure/page5.aspx 0 1 9/16/2013
George http://X1.somehostname.net/page6.aspx 2 1 9/16/2013
George http://X1.somehostname.net/page7.aspx 2 1 9/16/2013
George http://X1.somehostname.net/page8.aspx 1 1 9/16/2013


I would like to show how many unique visits per date do I have. Date is weekly. In other words I would like to count unique SIDs per date.

Edited by - nietzky on 10/17/2013 15:07:32

James K
Flowing Fount of Yak Knowledge

3651 Posts

Posted - 10/17/2013 :  15:16:00  Show Profile  Reply with Quote
SELECT
	CheckDate,
	COUNT(DISTINCT SID) AS UniqueVisits
FROM
	YourTable
GROUP BY
	CheckDate;
Go to Top of Page

nietzky
Yak Posting Veteran

72 Posts

Posted - 10/18/2013 :  13:40:22  Show Profile  Reply with Quote
Thank you
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000