当前位置: 代码迷 >> 报表 >> DBA,复杂的存储过程
  详细解决方案

DBA,复杂的存储过程

热度:248   发布时间:2016-05-05 08:04:35.0
求助DBA,复杂的存储过程
表结构

create table db1(

 devno varchar2(10), --设备号码
 value varchar2(10), --值
 time date, --数据保存时间

)

需求 :统计今年每个月该表值为1-5,5-10,10-15的记录数,转存到另外一张表。转存表记录设备号,记录数,值,时间。

------解决方案--------------------
insert into tbname 
select '1-5',count(*)
from tb
where value between 1 and 5;

insert into tbname 
select '1-5',count(*)
from tb
where value between 5 and 10;

insert into tbname 
select '1-5',count(*)
from tb
where value between 10 and 15;
  相关解决方案