select get_hrmsubname(f.subid) subname,
sum(case when f.status=1 then 1 else 0 end) status1,
sum(case when f.status=2 then 1 else 0 end) status2,
sum(case when f.status=3 then 1 else 0 end) status3,
sum(case when f.status=5 then 1 else 0 end) status5,
sum(case when f.status=4 then 1 else 0 end) status4,
sum(case when f.status=6 then 1 else 0 end) status6,
sum(case when f.status=7 then 1 else 0 end) status7,
sum(case when f.status=9 then 1 else 0 end) status9,
sum(case when f.status<>8 then 1 else 0 end) hj
from fna_pos_base f where f.status<>8
group by f.subid order by hj desc;
通过subid分组,统计各种status的合计
select fpb.id,fpb.asset_name, fpb.company, fpb.pos_machinenum,fpb.pos_merchantnum,
decode(fpb.status,1,'未领用',2,'城市领用',3,'个人领用',4,'调拨中',5,'领用中',6,'归还中',7,'报废中',9,'修改中') status
from fna_pos_base fpb where fpb.id=862
nvl(wb.isread,0) isread