Reputation: 141
There are multiple way to get first row from each group, but none of my idea is working with access2010.
Do you have a solution to get first row in access2010 ?
Or
ID Name Age
1 Name1 3
2 Name2 4
3 Name1 2
4 Name2 5
It should get the top row in each group (name column) so the output would be
1 Name1 3
2 Name2 4
Upvotes: 0
Views: 55
Reputation: 4069
Here's a solution that still uses a sub query, but only once, instead of on each record.
SELECT T1.*
FROM mytable AS T1
WHERE T1.id IN (SELECT First(T2.id)
FROM mytable T2
GROUP BY T2.name)
Upvotes: 2
Reputation: 2303
select * from table t1 where ID in
(sel min(ID) from table where t1.name=name);
Upvotes: 0