General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
This should do it:
SELECT t.PrimaryKey, t.SecondaryKey FROM Table AS t
WHERE t.PrimaryKey IN (SELECT TOP 1 MIN(PrimaryKey) FROM Table WHERE SecondaryKey = t.SecondaryKey)
Vlad
>Assuming I extract two fields from a table. The first field is the primary key and the second field is the secondary key which may occurs more than once in the result.
>
>I would like to have the result to only include the first primary key of the group. Which means, I need to first record of that group which was created.
>
>So, before having the need to group, I had a SQL like this:
>
>SELECT PrimaryKey,SecondaryKey FROM Table INTO CURSOR TEMP
>
>That result would extract several occurences of the same secondary key. So, it may looks like this:
>
>000001 000002
>000002 000002
>000003 000003
>000004 000002
>000005 000002
>000006 000003
>
>I would like to have this:
>
>000001 000002
>000003 000003
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only