Have a table that holds the price of a vessel and the NADA price of a vessel (both ints)
I need to return the top 25 of highest % below NADA
Here's the formula:
(NADA price - listing price) / NADA price * 100
My confusion lies on where to start with this. should I calculate this from the db and LIMIT 25 in some sort of temporary table (have never done this before) or should I get all data back and then sort and then do a for loop with < 26 ??
$hlist = mysql_query("select * from VESSEL");
$hrow = mysql_fetch_assoc($hlist);
$per = ($hrow["NADA"] - $hrow["PRICE"])/ $hrow["NADA"] * 100;
for($h = 0; $h < 26; $h++){
result list should look like:
16.21
16.15
15.37
8.60
etc...
The formula works great when I pull back all results..but I cm performing the formula afterward and have no way to sort the result set on it.
I appreciate any help... I am stuck on this.