I found the problem. I was giving the same name to the field in my cursor as the original table - sele val(xyz) as xyz. Once I changed this - sele val(xyz) as abc - it worked fine. It doesn't do this in your sample if I change to xyz to cField, though. Well, that's odd.
Regards,
E.R.
>>It looks like the sort is happening before the val conversion because negative numbers aren't at the top. Is there anything I can do in the SQL statement to make this work correctly?
>
>Works fine for me:
>
>
CREATE CURSOR temp1 (cField c(10))
>APPEND BLANK
>REPLACE cField WITH '3'
>APPEND BLANK
>REPLACE cField WITH '2'
>APPEND BLANK
>REPLACE cField WITH '-1'
>APPEND BLANK
>REPLACE cField WITH '9'
>SELECT VAL(cfield) as xyz FROM temp1 ORDER BY xyz
>
>Shows, -1, 2, 3, 9 for me.
Regards,
E.R. Gilmore