select sname from student --年龄 where sage=(select max(sage) from student where snativeplace=(select snativeplace from (select snativeplace,count(*) s from student where ssex='男' group by snativeplace) where s=(select max(s) from (select snativeplace,count(*) s from student where ssex='男' group by snativeplace)))) --地区 and snativeplace=(select snativeplace from (select snativeplace,count(*) s from student where ssex='男' group by snativeplace) where s=(select max(s) from (select snativeplace,count(*) s from student where ssex='男' group by snativeplace)) );
时间: 2024-04-08 20:33:16 浏览: 94
您的问题是:查询年龄最大且地区人数最多的男生的姓名。
以下是查询语句:
```sql
SELECT sname
FROM student
WHERE sage = (
SELECT MAX(sage)
FROM student
WHERE snativeplace = (
SELECT snativeplace
FROM (
SELECT snativeplace, COUNT(*) s
FROM student
WHERE ssex = '男'
GROUP BY snativeplace
)
WHERE s = (
SELECT MAX(s)
FROM (
SELECT snativeplace, COUNT(*) s
FROM student
WHERE ssex = '男'
GROUP BY snativeplace
)
)
)
AND snativeplace = (
SELECT snativeplace
FROM (
SELECT snativeplace, COUNT(*) s
FROM student
WHERE ssex = '男'
GROUP BY snativeplace
)
WHERE s = (
SELECT MAX(s)
FROM (
SELECT snativeplace, COUNT(*) s
FROM student
WHERE ssex = '男'
GROUP BY snativeplace
)
)
)
);
```
这个查询语句会返回年龄最大且地区人数最多的男生的姓名。
阅读全文