开发者学堂课程【新电商大数据平台2020最新课程:电商项目之交易类指标统计表 SQL 实现】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/640/detail/10569
电商项目之交易类指标统计表 SQL 实现
将表格创建一下,来实现 SQL。根据上一节课的表,去取数据即可。
创建一下交易类指标统计表:
直接 select from,订单流水表放在第一个。条件复制一下,继续装一个维表。继续供应商信息表,然后拿到 pr 等,od 里好像有相关代码,统一拿 od,接着判断取值。
insert ovenrite table ads nshop. ads nshop busi stat partitionbdp_day='20200321')
select
oc. customer gender,
oc. customer age range,
oc, customer natives,
pr. category code,
su. supplier _type,
count(distinct (case when od order status< then od. order id end)) busi _succ_orders
sum(case when od. order status7 then od. payment money end) busi succ amounts,
count(distinct (case when od. order_status< then od. customer_ id end)) busi_succ_users,
count(distinct (case when od. order_status< then od. product_ code end)) busi_succ_products,
count(distinct (case when od. order_status>7 then od. order id end) busi_fail_orders
sum(case when od. order status7 then od. payment money end) busi fail amounts
from
dwd_nshop. nshop orders details od
join
ods nshop. ods 02 customer oc
on
od. customer id=oc, customer id
join
ods nshop. dim pub product pr
Fon
pr product codeaod. product code
join
ods nshop. dipub supplier su
on
od. supplier_code=su. supplier code
where
od. bdp_day='20200321
group by
oc. customer _gender,
oc. customer_age range,
oc. customer_natives,
pr.category_code,
su. supplier_type
按照表格来,比如交易成功订单数,金额,买家等,第一个是订单的成功数,这就是所统计的第一个订单。
不填金额,看一下买家数,然后金额 sum,然后频繁的接换,再往下是商品数。接下来交易失败的订单数,失败的金额,把所有的复制。
任务还在跑,最后一个是没有数据,没有失败,把数据插入,插入进去交易类指标统计完成。
广告类说要之后,所有指标就完成。