>>PrimaryKey PrimaryKeyChildTable ChildTableField >>1 1 0 >>4 5 1 >>8 6 2 >>>>
>>PrimaryKey PrimaryKeyChildTable ChildTableField >>1 1 0 >>4 5 1 >>4 6 2 >>5 8 1 >>5 8 2 >>8 6 2 >>>>
>>PrimaryKey PrimaryKeyChildTable ChildTableField >>1 1 0 >>4 5 1 >>5 8 1 >>8 6 2 >>>
>DECLARE @test TABLE (PrimaryKey int PRIMARY KEY, PrimaryKeyChildTable int, ChildTableField int) >INSERT INTO @test >YourQuery goes here > > >SELECT test.* >FROM @test test >INNER JOIN (SELECT PrimaryKey, MIN(PrimaryKeyChildTable) AS PrimaryKeyChildTable > FROM @test > GROUP BY PrimaryKey) Tst >ON Test.PrimaryKey = Tst.PrimaryKey AND > Test.PrimaryKeyChildTable = Tst.PrimaryKeyChildTable >If you have two identical mimimum records (two same min primarykeychildtable), the above query will return both of them.