[SOLVED] MySQL or php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

[SOLVED] MySQL or php?

Post by Todd_Z »

I am querying a table for the sums of a couple rows - and so I used SUM(`xxxxx`) AS `sumx`, SUM(`yyyyyy`) AS `sumy` But then i want to sort them by the division of sumy into sumx, so i figured i could do `sumx` / `sumy` = `per` then order by `per` DESC at the end. However, I am getting an error that says that `sumx` and `sumy` dont exist. What to do?
Last edited by Todd_Z on Fri Oct 07, 2005 2:20 pm, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

SUM('xxxxxx') / SUM('yyyyyy') AS `per`

The results are cached for each expression so it's only processed once ;)
Post Reply