php ci group by,group by case when 的问题

Try!

select sn.seller_id,

sn.count,

allcount.cnt,

round(sn.cnt * 100 / allCount.cnt, 2) rate

from (select count(id) count,

sn.seller_id

from TPMS_Pur_RegSn sn

where status = 2

and sn_source = 3

group by sn.seller_id) sn,

(select count(sfsn.serial_number) cnt,

decode(ph_type, 113, ph.zg_id, 115, tmp.parent_zg_id) seller_ids

from TPMS_Stock_FlowSn sfsn,

TPMS_Pur_PhPdt ppp,

TPMS_Pur_Ph ph,

TPMS_Cust_Info ci,

TPMS_Zg_Info tmp

where sfsn.OUT_FLOW_ID = ppp.list_id

and ph.ph_id = PPP.PH_ID

and ci.cust_id = ph.cust_id

and ph.SECOND_ZG_ID = tmp.zg_id(+)

and ph_type in (113, 115)

group by decode(ph_type, 113, ph.zg_id, 115, tmp.parent_zg_id)) allCount

where sn.seller_id = allCount.seller_id;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值