SELECT * FROM mytable m1 WHERE UniqueId IN ( SELECT MIN(UniqueId) FROM mytable m2 WHERE m2.GroupField = m2.GroupField )Or
SELECT MIN(UniqueId) AS UniqueId, GroupField1, GroupField2 ; FROM mytable GROUP BY GroupField1, GroupField2 ; INTO CURSOR crsMin SELECT * ; FROM mytable WHERE UniqueId + GroupField1 + GroupField2 IN ( ; SELECT UniqueId + GroupField1 + GroupField2 FROM crsMin ) ; INTO CURSOR crsResult>I have a SQL which contains a GROUP BY clause. For the record that will be extract for each group, I need to extract the oldest one. I have a primary field that could be used for that. Basically, the lowest value in the primary field determines the first record that was created in that group. I'm trying to find the best approach in the SQL to achieve that.