在mysql有个表user,
id name age
1 tonny 18
1 wendy 30
1 james 25
1 simon 22
1 flynn 35
1 nancy 42
1 olivia 51
1 linda 20我想统计出不同年龄段的人数,
年龄段 人数
18-20 2
21-30 3
31-40 1
41-50 1
>50 1
请问上面的数据 语句该怎么写,请高手指教,不胜感激,多谢!!!
id name age
1 tonny 18
1 wendy 30
1 james 25
1 simon 22
1 flynn 35
1 nancy 42
1 olivia 51
1 linda 20我想统计出不同年龄段的人数,
年龄段 人数
18-20 2
21-30 3
31-40 1
41-50 1
>50 1
请问上面的数据 语句该怎么写,请高手指教,不胜感激,多谢!!!
解决方案 »
- VC编程,读取mysql数据库表时提示unhandled exception in installbase.exe(LIBMYSQL.DLL):0xc00000
- 关于多个相同数据库数据整合的问题
- 50分求一条SQL语句
- mysql_error() 问题
- 关于用MATCH()和AGAINST()进行全文搜索时数据显示不出的问题
- 问条sql语句
- 请问哪儿有数据库的入门级学习资料下载?
- MySql 新手碰到棘手问题 请各位大虾帮忙 关于把查询结果作为列名并统计列名下的结果
- JSP MySQL乱码问题!
- mysql 根据父节点id获取父节点和所有子节点
- 有什么可以存放多个ID数据?
- MySql关于root用户的密码
select count (1) AS 'No','18-20' as 'age'
into #A
from mytest
where age in (18,19,20)select count (1) AS 'No','21-30' as 'age'
into #B
from mytest
where age in (18,19,20)select count (1) AS 'No','31-40' as 'age'
into #C
from mytest
where age in (18,19,20)select count (1) AS 'No','41-50' as 'age'
into #D
from mytest
where age in (18,19,20)select count (1) AS 'No','UP 50' as 'age'
into #E
from mytest
where age > 50SELECT * FROM #A,#B,#C,#D,#Echange table name whatever you like .