Is it possible to sort on a calculation of 2 rows in mySQL? For example, I have 2 rows, lp and ap I’m trying to do something like this:
SELECT * from myTbl WHERE 1 ORDER BY (lp/ap)
Which isn’t throwing an error, but its also not sorting by the results of that calculation. Is there a way to do this, or do I have to store lp/ap in the database?
Yes, it is possible, and it does work. Check out the following test:
SELECT a.a, a.b FROM a ORDER BY (a/b);would return the same results.