Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cool way to eliminate duplicate column values?
Message
De
09/04/2001 02:05:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/04/2001 14:05:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00493142
Message ID:
00493443
Vues:
15
>>Would this work ?
>>
select distinct myField, recno() as rcno ;
>> from myTable into cursor crsUnique nofilter
>>select * from mytable where recno() in (select rcno from crsUnique)
>
>It sure looks like it would work. Here's a method I came up with that does work but may depend on internal implementation of SELECT-SQL GROUP BY to get correct results.
>
>Suppose I have work orders for parts I make (many-to-many relationship) and I want to create a table containing just the initial work order for each part. I can assume that the lowest work order number for a given part number is the initial work order for that part. So...
>
>
>SELECT partnum,wonum;
>  FROM workorders;
>  ORDER BY partnum,wonum desc;
>  INTO CURSOR uniq_wos NOFILTER
>SELECT partnum,wonum;
>  FROM uniq_wos;
>  ORDER BY partnum;
>  GROUP BY partnum;
>  INTO CURSOR uniq_wos
>
>
>This works because (apparently) GROUP BY selectitem returns the row of the last selectitem it finds in the source set as the representative row of the group....(makes sense if you're summing, averaging, etc). However, though it stands to reason that GROUP BY should work this way by definition, I do not know if that is a fact ... or it is just the way my version of VFP implements it.
>
>The reason for using two selects is because the selection of the group row apparently occurs prior to ordering the result set.
>
>If anyone can give further information about whether this method is risky or not I'd appreciate it.

It's a fact up till VFP6. I didn't check in VFP7 but can't see a reason fox team would change that.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform