<cfset percentOfVisits=visits / total_visits * 100>

490 is 3.0625% of 16,000

> -----Original Message-----
> From: Robert Orlini [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 15, 2002 3:59 PM
> To: CF-Talk
> Subject: percentage of hits
> 
> 
> Using SUM (I think) how can I get a percentage when comparing 
> it to a total? For example if #visits# is 490 and 
> #total_visits# is 16000. What is the code to extract the 
> percentage of 490 out of 16000?
> 
> Below is part of my code:
> 
> <cfquery name="getsomedata" datasource="log_stats">
> select url, count(url) as 'visits' from log_data
> group by url
> order by visits desc
> </cfquery> 
> 
> <cfquery name="datacount" datasource="log_stats">
> Select Count(*) AS total_count FROM log_data
> </cfquery>
> 
> <cfoutput query="datacount">#total_count#</cfoutput>
> 
> Thanks.
> 
> Robert Orlini
> HWW
> 
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to