如果表“people”包含“name”(varchar)和“birthdate”(日期)列,如何找到最老/最年轻的伙伴?
答案 0 :(得分:4)
SELECT name, birthdate FROM people ORDER BY birthdate ASC LIMIT 1
请注意,如果有两个或更多人具有相同的生日,则只返回一个。
答案 1 :(得分:1)
SELECT * FROM buddies
WHERE birthdate = (
SELECT MAX(birthdate) FROM buddies
)
LIMIT 1;
答案 2 :(得分:1)
如果你想加入关系
SELECT name
FROM people
where birthdate = (select max(birthdate) FROM people)