List:General Discussion« Previous MessageNext Message »
From:Yoed Anis Date:April 29 2004 5:51pm
Subject:RE: Order by price?
View as plain text  
Paul,

I tried doing that in one trial run, and I wasn't getting the $200 figure so
I gave up on that.
It seems like doing an order by that statement wouldn't have given me the
sort I wanted.
Don't know why that is though - in theory you should be right, I can try it
a bit more if your curious.

Best,
Yoed


-----Original Message-----
From: Paul DuBois [mailto:paul@stripped] 
Sent: Thursday, April 29, 2004 12:28 PM
To: Yoed Anis; mysql@stripped
Subject: Re: Order by price?


At 12:14 -0500 4/29/04, 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
>
>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)

Sounds like you want:

ORDER BY ROUND(($varA*(establishments^2)+$varB*(establishments)+$varC),2)

-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=1

Thread
Order by price?Yoed Anis29 Apr
  • Re: Order by price?Daniel Clark29 Apr
  • Re: Order by price?Robert J Taylor29 Apr
    • RE: Order by price?Yoed Anis29 Apr
    • Re: Order by price?Gerald Taylor29 Apr
  • Re: Order by price?Paul DuBois29 Apr
    • Re: Order by price?Robert J Taylor29 Apr
    • RE: Order by price?Yoed Anis29 Apr