Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select Distinct
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00779949
Message ID:
00779970
Views:
11
>>>Is there a way to Select...Distinct from a table and have the resulting records be un-ordered, or following the natural order of the source table? I have tried select ... Distinct and also Select...Group By and the results are always sorted.
>>>
>>>TIA,
>>Jeff,
>>
>>When you don't specify ORDER BY clause VFP is free to return records in any order. You should not relay on the order of records returned in this case. Here's how you can specify the order you want.
SELECT *, RECNO() AS RecordNo ;
>>  FROM mytable ;
>>  INTO CURSOR crsNumbered
>>SELECT DISTINCT ... ;
>>  FROM crsNumbered ;
>>  ORDER BY RecordNo
>
>Sergey,
>I don't think this will DISTINCT the result set. The recno() field will be distinct unto itself so even if all the other fields match, the additional field will cause the record to display, when it shouldn't.

Sorry, I forgot to mention that 'RecordNo' field shoudn't be included into query fields list.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform