急急急求一个统计问题

chenyonge 2011-03-23 07:56:11
有如下表
a b c
98.5 93.2 99.2
99.6 94.6 96.3
99.3 98.5 95.3
95.4 92.1 91.2
98.5 94.3 94.5


求以上表中,统计出以下区间出现的各数
如:91.5-93
93.5-95
95.5-98
98-100

请高手指点

...全文
100 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
一生望云 2011-03-23
  • 打赏
  • 举报
回复

select sum(case when a>91.5 and a<93 then 1 else 0 end) "91.5-93",
sum(case when a>93.5 and a<95 then 1 else 0 end) "93.5-95",
sum(case when a>95.5 and a<98 then 1 else 0 end) "95.5-98",
sum(case when a>98 and a<100 then 1 else 0 end) "98-100"
from tablename
union all
select sum(case when b>91.5 and b<93 then 1 else 0 end) ,
sum(case when b>93.5 and b<95 then 1 else 0 end) ,
sum(case when b>95.5 and b<98 then 1 else 0 end) ,
sum(case when b>98 and b<100 then 1 else 0 end)
from tablename
union all
.....

chenyonge 2011-03-23
  • 打赏
  • 举报
回复
a ,b,c 是一个表中的三个列,我这里只是举例子,实际可能列比这多呢
chenyonge 2011-03-23
  • 打赏
  • 举报
回复
一个表呀
quanhj 2011-03-23
  • 打赏
  • 举报
回复
什么意思 你是一个表里面有三个字段( a,b,c )么 还是有三个表(a,b,c)呀,



a b c
98.5 93.2 99.2
99.6 94.6 96.3
99.3 98.5 95.3
95.4 92.1 91.2
98.5 94.3 94.5

这个又是什么东西。需求不明确。
chenyonge 2011-03-23
  • 打赏
  • 举报
回复
不行呀,有很我列的,你那只求出一个列的中一个区间,我要求多个列中,多个区间,每个区间数值出现的次数
秋雨飘落 2011-03-23
  • 打赏
  • 举报
回复
有如下表
a b c
98.5 93.2 99.2
99.6 94.6 96.3
99.3 98.5 95.3
95.4 92.1 91.2
98.5 94.3 94.5
这个是什么啊,
select count(*) from biao where zhi > 91 and zhi < 98 这都能满足需求了。
chenyonge 2011-03-23
  • 打赏
  • 举报
回复
没有人回答呀,请高手指点

3,494

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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