Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Order by with local view
Message
From
22/11/2021 15:06:23
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
22/11/2021 09:14:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01682763
Message ID:
01682780
Views:
67
Jeffrey,

Two issues to check: ORDER and Field Type in the LV.

1) If you're using the View Generator, select View SQL from the menu and check that the order is definitely DESC. If not, then assuming you're using VFP9 or VFPA then you can add a DESC to the ORDER and when you close the View SQL, the order will be corrected.

2) Field Type: Is the source field N(2)? If you've set that as LV field type expecting only two digits, consider that N(2) also uses a "digit" for the negative, so you're limited to -1 to -9. In the following example, the -10 always pulls its record to the wrong end of the SELECT because of numeric overflow.
CREATE CURSOR test (myfield n(2),myField2 C(20))
INSERT INTO test VALUES (1,"One")
INSERT INTO test VALUES (3,"Three")
INSERT INTO test VALUES (7,"Seven")
INSERT INTO test VALUES (-10,"Minus Ten")
INSERT INTO test VALUES (-9,"minus nine")
SELECT * FROM test ORDER BY myfield
SELECT * FROM test ORDER BY myfield desc

If this is the cause, the LV field type can be safely changed; maybe N(3) or even consider integer.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform