您的位置:首页 > 业界新闻

互联网电商大数据环境 ——大数飓数据分析实践培训精华笔记(九)——电商核心业务知识之订单商品模块

2015-08-14 13:42 771 查看
商品信息汇总表

select

user_id,

sum(case

when pay_type not in (‘退货’,’拒收’) then

goods_amount

end) p_sales_cnt,-排除退拒销售数量

sum(case

when pay_type not in (‘退货’,’拒收’) then

goods_price * goods_amount

end) p_sales_amt,-排除退拒销售金额

sum(case

when pay_type not in (‘退货’,’拒收’) then

(goods_price – ‘优惠价’) * goods_amount

end) p_sales_cnt_amt,-排除退拒销售金额(扣促销减免)

sum(goods_amount) h_sales_cnt, -含退拒销售数量

sum(goods_price * goods_amount) h_sales_amt, -含退拒销售金额

sum((goods_price – ‘优惠价’) * goods_amount) h_sales_cut_amt, -含退拒销售金额(扣促销减免)

sum(case

when pay_type in (‘退货’) then

goods_amount

end) return_cnt,-退货商品数量

sum(case

when pay_type in (‘退货’) then

goods_price * goods_amount

end) return_amt,-退货商品金额

sum(case

when pay_type in (‘拒收’) then

goods_amount

end) return_cnt,-拒收商品数量

sum(case

when pay_type in (‘拒收’) then

goods_price * goods_amount

end) return_amt,-拒收商品金额

sysdate() dw_date

from itqsc.dm_b2c_orders_goods

where dt=’"${DT}"’

group by user_id

select user_id, first_cat_name

from (select user_id

first_cat_name,

row_number() over(distribute by a.user_id, sort by a.goods_amount desc, first_cat_name desc )

from(

select user_id, goods_id, goods_amount

from itqsc.dm_b2c_orders_goods

where dt=’"${DT}"’) a

join(select goods_id,

first_cat_name,

second_cat_name,

third_cat_name

from itqsc.ods_b2c_goods

where dt=’"${DT}"’

group by goods_id,

first_cat_name,

second_cat_name,

third_cat_name) b

on (a.goods_id=b.goods_id)) a) b

where b.rn=1;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: