| Subject | RE: Possible to use FIRST 1 inside a group by? | 
|---|---|
| Author | Leyne, Sean | 
| Post date | 2015-07-29T16:58:57Z | 
Maya,
Try:
SELECT
T.ID
T.GroupID
T2.FKCode
T2.Value
FROM (
select MIN (ID) as ID, GroupID
from MyTable
GROUP BY GroupID
) T
JOIN MyTable T2 ON T2.ID = T.ID
Sean
            > Might not be the most efficient method, but this works:Unfortunately, it is least efficient method -- you will read each table row n^2 times
Try:
SELECT
T.ID
T.GroupID
T2.FKCode
T2.Value
FROM (
select MIN (ID) as ID, GroupID
from MyTable
GROUP BY GroupID
) T
JOIN MyTable T2 ON T2.ID = T.ID
Sean