Re: Generating percentages of numbers

From: Date: Thu, 22 Feb 2001 11:48:41 +0000
Subject: Re: Generating percentages of numbers
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-41144@lists.php.net to get a copy of this message
At 11:47 22-2-01 +0100, Christian Reiniger wrote:
On Thursday 22 February 2001 00:04, Simon Garner wrote:
I have a database of numbers: TOTAL HITS: 1000 PAGE 1: 500 PAGE 2: 250 PAGE 3: 250 How can I query these numbers and display back a percentage number? For instance with the numbers above: PAGE 1: 50% PAGE 2: 25% PAGE 3: 25% Or is their a process by which to store numbers for easily getting this to work?
SELECT (hitcount / 1000) * 100 AS percentage FROM sometable Better (if it works): SELECT (hitcount / MAX(hitcount)) * 100 AS percentage FROM sometable
Should be sum then i think :)
-- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) I saw God --------- and she was black. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#41144) next »