Page 1 of 1

[SOLVED] MySQL or php?

Posted: Fri Oct 07, 2005 1:53 pm
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?

Posted: Fri Oct 07, 2005 1:55 pm
by feyd
SUM('xxxxxx') / SUM('yyyyyy') AS `per`

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