Re: Generating percentages of numbers

From: Date: Wed, 21 Feb 2001 23:04:49 +0000
Subject: Re: Generating percentages of numbers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41078@lists.php.net to get a copy of this message
From: "Blake S." <blake@webintention.com> > 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 Assuming you have a row in your table for each page.

« previous php.general (#41078) next »