关于分数段的问题

hyqwan 2007-11-28 08:39:04
我的表中有一列成绩,我想加入一列分数段列并对应加入一列在此分数段内的人数,请问怎么实现呢?
...全文
125 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawugui 2007-11-28
  • 打赏
  • 举报
回复
select id , fs , case when fs < 60 then '不及格'
when fs >= 60 and fs < 70 then '中'
when fs >= 70 and fs < 80 then '良'
when fs >= 80 and fs < 90 then '优'
when fs >= 90 and fs<= 100 then '棒及了'
else then '分数有误'
end
from tb
dawugui 2007-11-28
  • 打赏
  • 举报
回复
select id , fs , case when fs < 60 then '不及格'
when 60 to 70 then '中'
when 70 to 80 then '良'
when 80 to 90 then '优'
when 90 to 100 then '棒及了'
else then '分数有误'
end
from tb
fcuandy 2007-11-28
  • 打赏
  • 举报
回复
随手敲的,不排除手误

select x.*,s,e,v,cnt
from tb x
inner join
(
select s,e,v,count(*) cnt
from tb a
inner join
(select s=90,e=101,v='优'
union select 80,90,'良'
union select 70,80,'中'
union select 60,70,'级格'
union select 0,60,'不级格') b
on a.score>=s and a.score<e
group by s,e,v
) y
on a.score>=s and a.score<e

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧