Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Getting counts

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2011-10-25 : 13:30:55
I have a table that has an ID and a timestamp.
I am trying to make a chart on how many hits that come from an external page to my page. for from a specific page, the ID is 7 and I also insert a timestamp. I want to fring back a count of all hits for a specific ID per day. So, I would like to bring a count for each day this month. I would pass the proc ID 7 and I could also pass that this month has 31 days. Not sure if I can do this in SQL. Any Ideas?

Dave
Helixpoint Web Development
http://www.helixpoint.com

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-10-25 : 13:55:33
Here is a basic query that should get you going. If you are using a stored procedure you can bass in the ID and other values if you want to limit by a date range or something.
SELECT CAST(timestamp AS DATE) AS HitDate, COUNT(*) AS HitCout
FROM MyTable
WHERE IDENTITY = 7
GROUP BY CAST(timestamp AS DATE)
ORDER BY CAST(timestamp AS DATE)
Go to Top of Page
   

- Advertisement -