如题所述
用出生年份分组计数就行了,请参考下例:
假设表结构是
学生表(学号,姓名,生日(yyyy-mm-dd))
select year(生日) as 出生年份,
count(*) as 人数 from 学生表
group by year(生日);
如果直接有出生年份这个字段,那么语句可简化如下
select 出生年份,count(*) as 人数
from 学生表 group by 出生年份;
假设表结构是
学生表(学号,姓名,生日(yyyy-mm-dd))
select year(生日) as 出生年份,
count(*) as 人数 from 学生表
group by year(生日);
如果直接有出生年份这个字段,那么语句可简化如下
select 出生年份,count(*) as 人数
from 学生表 group by 出生年份;
温馨提示:答案为网友推荐,仅供参考