Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting the sort order with mixed text/numbers
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00156320
Message ID:
00156333
Views:
36
Paul,

The ORDER BY has to be a field of the SELECT. Use

select vehicles.Status, vehicles.Vid, left( vehicles, 1 ) + PADL( substr( vehicles.Vid, 2 ), 2, "0" ) as sortby ...
order by status, sortby

>I've got a cursor I generate that has a ORDER BY clause that looks like:
>
>ORDER BY Vehicles.Status,Vehicles.Vid
>
>In my table these fields look like:
>
>Status VID
>Available M1
>Available M2
>Available M4
>Available M3
>Available M10
>
>There are some other settings of Status, but that's not where my problem is. What I'd like to see if all of the Status entries are "Available" is a list that looks like:
>
>M1
>M2
>M3
>M4
>M10
>
> Instead, it shows up like:
>
>M1
>M10
>M2
>M3
>M4
>
> I know it's because it's treating the field as alphanumeric, not just numbers. I tried changing the ORDER BY clause to read:
>
>ORDER BY Vehicles.Status,VAL(SUBSTR(Vehicles.Vid,2))
>
>..so it reads the numeric value instead, but VFP doesn't seem to like it. It gives me an error about some missing fields (Column "Status" not found). Is there another way I can do this?
>
>Thanks,
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform