I don't have MySQL installed, but this is how I'd do it in MSSQL (and  
I don't see why it wouldn't work for you...):

SELECT
        *,
        OrderValue = CASE WHEN MinPrice > MaxPrice THEN MinPrice ELSE  
MaxPrice END
FROM
        mytable
ORDER BY
        OrderValue DESC


Seb


Seb Duggan
Web & ColdFusion Developer

e:      [email protected]
t:      07786 333184
w:      http://sebduggan.com

On 14 Dec 2008, at 03:26, Jim McAtee wrote:

> I have a table with two columns containing min and max values
>
> minprice INT
> maxprice INT
>
> The max price may not be present and is set to zero when that's the  
> case,
> so data might look like:
>
> 1 5
> 5 0
> 3 10
> 8 0
> 6 0
>
> I want to order by the larger of the two column values
>
> ORDER BY Max(minprice, maxprice) DESC
>
> But SQL's MAX() can't be used like this since it's an aggregate  
> function.
> Is there a MySQL function that would do this?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316744
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to