Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get PK Value for unique field value
Message
From
24/09/2004 14:57:48
 
 
To
24/09/2004 14:21:36
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00945785
Message ID:
00945836
Views:
21
See my response to Sergey.

>Try something like:
>
>
SELECT Min(pk) as pk, value FROM tablename GROUP BY value
>
>Alan
>
>>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?
Thanks,
Dan Jurden
djurden@outlook.com
Previous
Reply
Map
View

Click here to load this message in the networking platform