Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Order by with local view
Message
From
22/11/2021 17:47:36
 
 
To
22/11/2021 15:06:23
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01682763
Message ID:
01682782
Views:
36
Thanks. Yes. So the field is (N 10 ) with 2 decimal places

Some data that currently exists is: -35.01, -13.18, 4.56, 17.20.

Right now regardless of add DESC or ASC in the sql view, the negative numbers appear at the top of the table (i.e. -35.01, -13.18, 17.20, 4.56).

I'm even placing a requery in the command window and browsing the view again, same results. Changing the field type to integer would not work either b/c i need the decimal places just in case the data is just that. Yes I am using VFP 9.0 btw.



>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.
Thanks in Advance.

J. Turner
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform