oracle报错:不是单组分组函数

2025-03-23 16:45:09
推荐回答(2个)
回答1:

select p.requi_form,
sum(decode(p.requi_form, '0', r.bid_amount, 0)) a,
sum(decode(p.requi_form, '1', r.bid_amount, 0)) b,
sum(decode(p.requi_form, '2', r.bid_amount, 0)) c,
sum(decode(p.requi_form, '3', r.bid_amount, 0)) d,
sum(decode(p.requi_form, '4', r.bid_amount, 0)) e,
sum(p.bid_amount) 采购金额,
sum(r.bid_amount) 招标采购金额,
sum(r.bid_amount) / sum(p.bid_amount) 招标采购率
from cg_purchase_project p,
cg_purchase_report r
where r.purc_pro_id = p.purc_pro_id
and p.purc_pro_state != 11
group by p.requi_form
order by p.bid_team;

回答2:

非聚集函数列,要刚到group by 列表中:



select fno,max(decode(category,'l1',value)) l1,max(decode(category,'l2',value)) l2,max(decode(category,'l3',value)) l3,max(decode(category,'l4',value)) l4,max(decode(category,'l5',value)) l5,max(decode(category,'l6',value)) l6 
from table
group by fno