sort by `value` problem?
Posted: Sun Jul 14, 2002 10:43 am
the following sql query doesnt work as i expect. i want the records to be sorted order by pprice (i want it treated as integer) but it sorts them as if they were char values.
SELECT price,
@ham:=(price & 0x0FFFFFFF),
@cur:=(price >> 28 ),
if((@cur=1),(@ham),(if((@cur=2),(@ham*$dolr_val/100),(@ham*$euro_val/100)))) as pprice
from tbl1 order by pprice;
price is a 32bit INT field. first 4 bits used for currency info and the rest 28bits used for price. pprice is produced by multiplication of cur and ham
thanks for your interests.
SELECT price,
@ham:=(price & 0x0FFFFFFF),
@cur:=(price >> 28 ),
if((@cur=1),(@ham),(if((@cur=2),(@ham*$dolr_val/100),(@ham*$euro_val/100)))) as pprice
from tbl1 order by pprice;
price is a 32bit INT field. first 4 bits used for currency info and the rest 28bits used for price. pprice is produced by multiplication of cur and ham
thanks for your interests.