List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:February 2 2000 4:26pm
Subject:Re: order by price, but it's a varchar
View as plain text  
In the last episode (Feb 02), Mr. Anthony R.J. Ball said:
> 
>   We have a product database, which has a two part product name. The
> first part groups products that are the same type, the second part
> designates it's attributes (small,red, various things). in our
> category pages we select with a group by on the first part of the
> product name, IE SELECT product,price FROM products GROUP BY product
> 
> what we want is to get the product with the lowest price, however
> this doesn't seem to work right, since the price is a varchar. How
> can this be done (short of changing price to be a float field).

Try using "ORDER BY price+0" to force the price field to be treated as
a number.

-- 
	Dan Nelson
	dnelson@stripped
Thread
order by price, but it's a varcharMr. Anthony R.J. Ball2 Feb
  • Re: order by price, but it's a varcharDan Nelson2 Feb
    • Re: order by price, but it's a varcharMr. Anthony R.J. Ball2 Feb
  • Re: order by price, but it's a varcharsasha2 Feb
    • Re: order by price, but it's a varcharMr. Anthony R.J. Ball2 Feb
  • Re: order by price, but it's a varcharPaul DuBois2 Feb