You are here: Re: arrays... and long-term-novice « PHP Programming Language « IT news, forums, messages
Re: arrays... and long-term-novice

Posted by Steve on 10/25/05 13:34

> I need to sort some values by percentage, and don't know how...

Let MySQL do the work for you:

SELECT @TOT:=SUM( `usage` )
FROM mytable

and in the same session, calculate all the percentages and return just
the first one:

SELECT `usage`, `usage` / @TOT AS `perc`
FROM mytable
ORDER BY `perc`
LIMIT 1

No need to learn about arrays just yet 8-)

---
Steve

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация