Yoed Anis wrote:

I'm having trouble with this query:
SELECT
CONCAT('$',ROUND(($varA*(establishments^2)+$varB*(establishments)+$varC),2))
as price FROM table ORDER BY price



Hint: you've made this a "string" comparison using CONCAT, i.e., alphabetical, not numerical, sorting rules apply.

How about

SELECT ROUND(($varA*(establishments^2)+$varB*(establishments)+$varC),2) as price FROM table ORDER BY price;

Then using a printf/sprintf type formatting statement on the application/presentation layer to show to the user?

What is the application language y

A note first. The column "establishments" is an int(10), as you see I am
taking this number through a formula, and I want the result of this formula
to be rounded to two decimal places, and to stick a "$" sign in front of it
so I can easily display it on a table.

However here is the problem, in ASC order I get these results:
$110.46 $173.86
$208.02
$22.62 $22.62


And in DESC order I get these results:
$90.44
$79.94
$50.10
$48.33 (with the max result 208 for instance at the 3rd from very bottom, 110 is at
very bottom)



Any help in solving this would be greatly appreciated. Thanks, Yoed




HTH,

Robert Taylor
[EMAIL PROTECTED]


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to