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.
我有一个类似的列表:
Name Age Charles 18 Anna 20 Anna 19 Tomas 44 Karla 13 Charles 88
我会写一个 JPQL 语句给我:
Charles 18 Anna 20 Tomas 44 Karla 13
换句话说,我怎样才能得到一个不关心年龄的具有唯一名称的列表?
此致
卡尔
如果实在不在意年龄,就不要选了:
select distinct u.name from User u
如果您想获得每个用户的有效年龄,但不在乎哪一个,请选择年龄的最小值或最大值:
select u.name, max(u.age) from User u group by u.name