Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有多种方法可以从每个组中获取第一行,但我的想法都不适用于 access2010。
您有解决方案来获得 access2010 的第一行吗?
或者
ID Name Age 1 Name1 3 2 Name2 4 3 Name1 2 4 Name2 5
它应该在每个组(名称列)中获得第一行,因此输出将是
1 Name1 3 2 Name2 4
这是一个仍然使用子查询的解决方案,但只使用一次,而不是在每条记录上。
SELECT T1.* FROM mytable AS T1 WHERE T1.id IN (SELECT First(T2.id) FROM mytable T2 GROUP BY T2.name)
select * from table t1 where ID in (sel min(ID) from table where t1.name=name);