读书人

DBA复杂的存储过程

发布时间: 2012-04-26 14:01:31 作者: rapoo

求助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;

读书人网 >行业软件

热点推荐