一条sql语句。。

Misted_Kira 2011-07-14 04:56:01
一张表里有个字段是一个公司的注册资金 我想要查出资金10w以下,10-50w,100w以上这些范围的数据条数, 用一条sql语句 或者视图都可以,那位高手帮下忙啊,最好考虑下效率问题。
...全文
76 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Misted_Kira 2011-07-15
  • 打赏
  • 举报
回复
我用视图去做了 ,谢谢大家的热心解答、 结贴,均分。
youshang444 2011-07-14
  • 打赏
  • 举报
回复
select sum(case when zijin<10 then 1 else 0 end) 10Wyixia,sum(case when 10W<zijin<50W then 1 else 0) 10-50W ..... from table.
Rotel-刘志东 2011-07-14
  • 打赏
  • 举报
回复
如果作为列的话用union all是不行的,就应该用case expresstion when ....
njlywy 2011-07-14
  • 打赏
  • 举报
回复
语句间用union all…
Rotel-刘志东 2011-07-14
  • 打赏
  • 举报
回复
select count(case amout<10000 then 1 ese 0 end ) "10万以内"
count(case amount>=10000 and amount<500000 then 1 else 0 end) "10-50",
...
from tb1
ICE-word 2011-07-14
  • 打赏
  • 举报
回复
selec * from table where A<10W
union all
selec * from table where A>=10W and < 50W
union all
selec * from table where A>50W and <100W
tangren 2011-07-14
  • 打赏
  • 举报
回复
你是要显示详细信息还是统计个数
如果是要显示详细数据可以使用union all
如果是要统计个数,可以使用case
select count(case amount<100000 then 1 else 0 end) "10万以下",
count(case amount>=100000 and amount<500000 then 1 else 0 end) "10-50万",
.........
from table1;
luo_riser 2011-07-14
  • 打赏
  • 举报
回复
用union all吧
horizonlyhw 2011-07-14
  • 打赏
  • 举报
回复
<10W
union all
>=10W and < 50W
union all
>50W and <100W

3,491

社区成员

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

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