*如果有两个或多个相同的值,我该怎么做才能从列中获取最小值?
name | age
--------------
Peter | 25
Andre | 31
John | 18
Lisa | 31
Dick | 29
Jen | 18
我想要最年轻的人的名字。min(age) 只返回第一个。
SELECT *
FROM table
WHERE age = (SELECT min(age) FROM table)
如何使用GROUP_CONCAT()
将所有名称分组到一个列表中。
就像是:
SELECT GROUP_CONCAT(name), age FROM people GROUP BY age ORDER age ASC LIMIT 1;
select * from yourTable where age = (select MIN(age)) from yourTable)
您可以使用
select name,age from test.new_table where age = (select min(a.age) from test.new_table a)
SELECT * FROM table ORDER BY age LIMIT 1;