现有个表 其中有考试成绩,比如
表A姓名 成绩 性别
张三 80 男
李四 55 男
王五 86 男
赵六 90 男现在想根据分数统计人数 想实现60以下多少人,60-84分多少人,85以上多少人 查询结果如
60以下 1
60-84 1
85以上 2
表A姓名 成绩 性别
张三 80 男
李四 55 男
王五 86 男
赵六 90 男现在想根据分数统计人数 想实现60以下多少人,60-84分多少人,85以上多少人 查询结果如
60以下 1
60-84 1
85以上 2
解决方案 »
- 查询子节点最多的父节点
- 如何无人值守安装 sql server 2005 express
- 如何判断某个字段是否存在重复记录?
- 这个查询还是不会写?
- 100分求数据库课设
- 问个查询效率问题,我两张表数据都是60万,我sql语句是:select * from test08 a where a.nbr not in(select nbr from disct@towe where
- 我的sql Agent 启动不起来?
- 求教在数据库:a的所有表所有列中查找其中一项="aaa"的所有表
- 为什么我的mssql装不上去了!!!(附出错图)
- 关于“SQL Server 身份验证”
- 数据同步急救!!!!!!!!!!
- 我想查询出相同的cuno列对应的cadt列中其最小的值,
union all
select '60-84' as [类型],count(1) as [人数] from [表] where [成绩]>=60 and [成绩]<84
union all
select '85以上' as [类型],count(1) as [人数] from [表] where [成绩]>=85
select
count(case when [成绩]<60 then 1 else 0 end) as [60以下],
count(case when [成绩]>=60 and [成绩]<85 then 1 else 0 end) as [60-84],
count(case when [成绩]>=85 then 1 else 0 end) as [85以上]
from [表]
when [成绩]>=60 and [成绩]<85 then '60-84'
when [成绩]>=85 then '85以上' end as 类型,
count(*) 人数 from tb
group by case when [成绩]<60 then '60以下'
when [成绩]>=60 and [成绩]<85 then '60-84'
when [成绩]>=85 then '85以上' end