tmp_house,字段为:小区编号、楼幢编号、单元编号、室号、面积、备注
tmp_test,字段为:户型 、个数、总面积、平均面积
题目:存储过程编写
1、传入参数:某个楼幢的编号
2、内容:
1)循环处理指定楼幢下面的每个房屋,给面积<=80的,备注字段写上‘小户型’三个字;80<面积<=140的,备主字段写上‘中房型’三个字,面积>140的,写上‘大户型’三个字。
2)将上述楼幢下面的房屋根据房型统计出结果,插入上述表中tmp_test
题目里没写字段类型,自己改下
create procedure test_func(i_lzbh number) is
begin
for rec in (select t.rowid rd from tmp_house t where 楼幢编号 = i_lzbh) loop
update tmp_house
set 备注 = case
when 面积 <= 80 then
'小户型'
when 面积 <= 140 then
'中房型'
else
'大户型'
end
where rowid=rec.rd;
end loop;
insert into tmp_test(户型 ,个数,总面积,平均面积)
select 备注, count(1), sum(面积), avg(面积)
from tmp_house where 楼幢编号 = i_lzbh
group by 备注;
commit;
end;