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
 General SQL Server Forums
 New to SQL Server Programming
 Average Count problem

Author  Topic 

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-08-20 : 04:33:58
Just seeing if any one can help on this one, we currently have a simple log table for a website that logs the amount of times that the certain article on the website has been viewed

Table is

ArticleId – DateAccessed

Each time a user accesses the table a date is entered into the DateAccessed Column, and from there a SQL statement is run to count the about of times the article has been accessed.

However due to the articles being inserted onto the website at different time obviously the article that has been on the website longest has the highest count.

I was wondering in another table we do have a dateInserted, date that shows when the article was put onto the website. What I need to know is there a way to get a average from the count dependent on the about of time the article has been on the website

I was looking at the Datediff function but not sure if this would work

Any advice people


***************************
Life is for having Fun, and then a little work

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-20 : 05:16:31
yup. just use COUNT(DateAccessed)*1.0/DATEDIFF(dd,DateAdded,GETDATE())
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-08-20 : 09:04:21
Cheers that one works a treat

***************************
Life is for having Fun, and then a little work
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-20 : 09:17:28
quote:
Originally posted by NeilG

Cheers that one works a treat

***************************
Life is for having Fun, and then a little work


You're welcome
Go to Top of Page
   

- Advertisement -