41 lines
1.9 KiB
MySQL
41 lines
1.9 KiB
MySQL
|
select
|
||
|
d.organ_code
|
||
|
, d.organ_name
|
||
|
, d.comm_id
|
||
|
, d.comm_name
|
||
|
, date_format(a.createTime,'%Y%m') create_ym
|
||
|
, b.categoryLevel1 category
|
||
|
, sum(a.salePrice - ifnull(a.refundCash,0)) sale_amt
|
||
|
, sum(case when skuid in ('124874622100769','126644461100769','161670412100769','161671313100769','163837882100769','167672495100769','167673766100769','168528115100769','169545207100769') then b.sale_amt - ifnull(a.refundCash,0) else 0 end) yht_amt
|
||
|
, sum(case when skuid in ('210627208100769','210627209100769','210627910100769','210625842100769','212609619100769','212609630100769','212603476100769','212603435100769','212603991100769','212603992100769','212603993100769','212300126100769','212298914100769','212299441100769','212299442100769','212299443100769','212299444100769','212297464100769','212297465100769','212296013100769','212314094100769','212314095100769','212314096100769','212328078100769','212328079100769','212294902100769','212292070100769','212287875100769','218885780100769','218884653100769','218884327100769','218692804100769','218691252100769','217847406100769','217479477100769') then b.sale_amt - ifnull(a.refundCash,0) else 0 end) xydj_amt
|
||
|
, count(*) order_num
|
||
|
, count(distinct skuid) sku_num
|
||
|
from dwd_innoveco_order_info_d a
|
||
|
left join (
|
||
|
select
|
||
|
orderNo
|
||
|
, salePrice * skuNum sale_amt
|
||
|
, skuid
|
||
|
, categoryLevel1
|
||
|
from dwd_innoveco_order_item_d
|
||
|
) b
|
||
|
on a.orderNo = b.orderNo
|
||
|
right join (
|
||
|
select
|
||
|
organ_code
|
||
|
, organ_name
|
||
|
, comm_id
|
||
|
, comm_name
|
||
|
, weim_comm_id
|
||
|
from dim_organ_mapping
|
||
|
) d
|
||
|
on a.vid = d.weim_comm_id
|
||
|
where d.comm_id is not null
|
||
|
and a.createTime is not null
|
||
|
group by
|
||
|
d.organ_code
|
||
|
, d.organ_name
|
||
|
, d.comm_id
|
||
|
, d.comm_name
|
||
|
, b.categoryLevel1
|
||
|
, date_format(a.createTime,'%Y%m')
|