select count(*) from people where height <= 190 group by (height/10)
union all
select count(*) from people where height > 190 ;
解决方案 »
- 如何设计显示基金净值图表的数据库
- 有没有access数据库转Oracle数据库的例子或资料
- 请问北京除了原厂,哪里培训oracle DBA比较好?
- oracle如何计算插入字段串的长度
- 请教高手! 10gR2登陆iSQL*Plus问题
- 这个问题,所有程序员都要注意了!!
- 我的后台数据库是Oracle8i,客户端前台程序用VB编写,在客户端还需要安装哪些和Oracle相关的东东?
- 重装win2000,重装oracle,原来的oracle目录还在,如何恢复数据?
- 提交数据的效率问题(在存储过程中)
- oracle 插入数据同时更新该数据的某一字段的触发器
- 我有1个insert 语句,1个delete语句,如果实现insert语句发生异常时继续执行下面的delete语句??
- 请教,如何在8i中使用clob
union all
select count(*) from people where height > 190 ;
union
select count(*),'151-160' from people where height between 151 and 160
union
select count(*),'161-170' from people where height between 161 and 170
union
select count(*),'171-180' from people where height between 171 and 180
union
select count(*),'181-190' from people where height between 181 and 190
union
select count(*),'h>=191' from people where height >=191
union all
select count(*) from people where height > 190 ;
本人是oracle门外汉!请推荐一本入门书,(本人原来做SQL server,算熟)
(select count(*) where height<150) as col1,
(select count(*) where height>=150 and height<160) as col2,
....
from dual;
本人是oracle门外汉!请推荐一本入门书,(本人原来做SQL server,算熟)
( select decode(sign(height - 150),-1,'150cm以下',sign(height - 160),-1,'150-160',sign(height - 170),-1,'160-170',sign(height - 180),-1,'170-180',sign(height - 190),-1,'180-190','190以上') range from people) a
group by a.range
sum(decode(sign(160-height)*sign(height-150),1,1,0)) 150-160,
sum(decode(sign(170-height)*sign(height-160),1,1,0)) 150-160,
sum(decode(sign(180-height)*sign(height-170),1,1,0)) 150-160,
sum(decode(sign(190-height)*sign(height-180),1,1,0)) 150-160,
sum(decode(sign(190-height,1,1,0)) 190以上
from table_name;
(select count(*) from people where height between 161 and 170) h160_170,
(select count(*) from people where height between 171 and 180) h170_180,
(select count(*) from people where height between 181 and 190) h180_190,
(select count(*) from people where height>190) h1190_over from people where rownum<=1;
group by round((height/100))
select a.range, count(*) from
( select decode(sign(height - 150),-1,'150cm以下',sign(height - 160),-1,'150-160',sign(height - 170),-1,'160-170',sign(height - 180),-1,'170-180',sign(height - 190),-1,'180-190','190以上') range from people) a
group by a.range
这里的decode是pl/sql里的还是T_sql里的?他的参数分别代表什么意思?
2 from people
3 group by trunc(height,-1) || '-' || trunc(height+10,-1);身高
--------------------------------------------------------------------------------
人数
----------
140-150
1170-180
2
return c;
elsif a=d then
return e;
...
else
return z;
end if;
请不要选择decode, case when 之类的处理方法
效率很低,严重占用服务器的内存空间
而且在表达上过分抽象!可读性差,不利于维护
多谢!!!