2

*如果有两个或多个相同的值,我该怎么做才能从列中获取最小值?

name   |   age
--------------
Peter  |   25
Andre  |   31
John   |   18
Lisa   |   31
Dick   |   29
Jen    |   18

我想要最年轻的人的名字。min(age) 只返回第一个。

4

5 回答 5

10
SELECT *
FROM table
WHERE age = (SELECT min(age) FROM table)
于 2013-02-26T10:40:57.310 回答
1

如何使用GROUP_CONCAT()将所有名称分组到一个列表中。

就像是:

SELECT GROUP_CONCAT(name), age FROM people GROUP BY age ORDER age ASC LIMIT 1;
于 2013-02-26T10:44:52.753 回答
0
select * from yourTable where age = (select MIN(age)) from yourTable)
于 2013-02-26T10:42:20.980 回答
0

您可以使用

select name,age from test.new_table where age = (select min(a.age) from test.new_table a)

于 2013-02-26T10:48:39.250 回答
-1
SELECT * FROM table ORDER BY age LIMIT 1;
于 2013-02-26T10:42:46.923 回答