Forums

ASP

This topic is locked

calculations in asp and vbscript

Posted 07 Jan 2002 14:03:31
1
has voted
07 Jan 2002 14:03:31 David Behan posted:
ASP and VBSCRIPT

Ok, got a stored procedure that will update the "hits" field in the database when a user accesses a particular record. That is grand and I can get the number of hits for each record.

Now what I want to do is get a total number of all the hits added together. Basically add all of the individual hits of each record to get a total number of hits. If someone can give me some basic code for this, that would be great.

Next is I want to show what percentage of hits each record got. So, this will be divide field "hits" for record_id by total number of hits multiplied by 100. Can someone supply me with this script as well.

Cheeurs in advance.

Dave
~~~~~~~~~~~~~~~~~~~~~~

C:/Dos
C:/Dos/Run
Run/Dos/Run

Replies

Replied 07 Jan 2002 14:28:59
07 Jan 2002 14:28:59 Owen Eastwick replied:
Set up some recordsets with the following SQL statements.

Total Hits: rsTotal

SELECT COUNT (AnyField) AS TotalHits
FROM HitsTable


Specific Hits: rsSpecific

SELECT COUNT (AnyField) AS SpecificHit
FROM HitsTable
WHERE TrackedItemID = n (WHere n is the ID number)

To calculate the percentages:

varTotal = rsTotal.Fields.Item("TotalHits".Value)
varSpecific = rsSpecific.Fields.Item("SpecificHits".Value)
varPercent = (varSpecific/varTotal) * 100

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Reply to this topic