select
t.shop_code,
t.shop_name,
t.area,
t.region,
t.district,
t.item_fst_classify_name,
t.item_sec_classify_name,
t.item_code,
t.item_name,
a.stat_date,
b.item_sale_cnt,
t.item_sale_amount,
t.item_discount_amount,
t.item_return_cnt,
t.item_return_amount,
t.item_sale_order_cnt,
a.order_count,a.business_days
from ads_mcht_single_item_analysis_di t
left join
(select sum(order_count) order_count ,shop_code ,business_days,stat_date
from ads_biz_order_sale_wi
group by shop_code,stat_date
) as a
on a.shop_code = t.shop_code
left join
(select sum(item_sale_cnt) item_sale_cnt, shop_code,stat_date ,item_code
from ads_mcht_single_item_analysis_di where stat_cycle='W'
group by shop_code,stat_date,item_code) as b
on b.shop_code = t.shop_code
|