Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get PK Value for unique field value
Message
 
 
À
24/09/2004 14:57:09
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00945785
Message ID:
00945847
Vues:
19
It depends on VFP version. The VFP8 and later with default SET ENGINEBEHAVIOR have the same requirements as SQl Server. Anyway, I don't see you mentioned in your previous posts that there're extra columns that have to be taken into consideration.

>Group Bys don't work in SQL like they do in VFP. You have to list every field in the SELECT list in the Group By clause.
>
>I have a solution that uses correlated subqueries that is working very well.
>
>Thanks for you time anyway.
>
>>That's different story.
SELECT MIN(PK) AS PK, Value
>>  FROM mytable
>>  GROUP BY value
>>-- OR
>>SELECT MAX(PK) AS PK, Value
>>  FROM mytable
>>  GROUP BY value
>>
>>
>>>I really don't care if it is the first or last. I really only want one.
>>>
>>>>Hi Dan,
>>>>
>>>>You have to define the meaning of "the first PK value" in terms of data in the table. IOW, which field defines the PK order and how.
>>>>
>>>>>I have a table that is using UNIQUEIDENTIFIER pk values. There is another character field that has duplicate values in it.
>>>>>
>>>>>For example (using integer pks for simplicity)
>>>>>
>>>>>
>>>>>PK   Value
>>>>>1    a
>>>>>2    b
>>>>>3    a
>>>>>4    c
>>>>>5    a
>>>>>
>>>>>
>>>>>I want a query that will give me the first PK value for each unique "Value". So I will get back:
>>>>>
>>>>>
>>>>>PK
>>>>>1
>>>>>2
>>>>>4
>>>>>
>>>>>
>>>>>How can I do this?
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform