成都建站推广,免费咨询律师在线,wordpress 提交,wordpress 文章投票插件文章目录 07#xff1a;服务域#xff1a;油站主题分析08#xff1a;服务域#xff1a;油站主题实现 07#xff1a;服务域#xff1a;油站主题分析 目标#xff1a;掌握油站主题的需求分析 路径 step1#xff1a;需求step2#xff1a;分析 实施 需求#xff1a;统计… 文章目录 07服务域油站主题分析08服务域油站主题实现 07服务域油站主题分析 目标掌握油站主题的需求分析 路径 step1需求step2分析 实施 需求统计不同维度下的油站主题指标的结果 分析 指标油站数量、新增油站数量 维度 日期维度天、周、月油站维度类型、省份、城市、地区客户维度类型、省份 数据表 事实表 fact_oil_station油站事实表 selectos_num,--油站个数current_new_os_num --新增油站个数
from fact_oil_station;维度表 dim_oilstation油站维度表 selectid,--油站idcompany_name,--公司名称province_name,--省份名称city_name,--城市名称county_name,--区域名称customer_classify_name,--客户名称customer_province_name--客户省份
from dim_oilstation;dim_date时间维度表 selectdate_id,--天week_in_year_id,--周year_month_id --月
from dim_date;实现分析 selecta.os_id,--油站idsum(a.os_num),--油站数量sum(a.current_new_os_num),--新增油站数量b.date_id,--天b.week_in_year_id,--周b.year_month_id, --月c.company_name,--公司名称c.province_name,--省份名称c.city_name,--城市名称c.county_name,--区域名称c.customer_classify_name,--客户名称c.customer_province_name--客户省份from fact_oil_station ajoin one_make_dws.dim_date b on a.dt b.date_idjoin one_make_dws.dim_oilstation c on a.os_id c.idgroup byb.date_id,--天b.week_in_year_id,--周b.year_month_id, --月c.company_name,--公司名称c.province_name,--省份名称c.city_name,--城市名称c.county_name,--区域名称c.customer_classify_name,--客户名称c.customer_province_name;--客户省份;小结 掌握油站主题的需求分析
08服务域油站主题实现 目标实现油站主题表的维度指标构建 实施 建表 -- 创建油站主题表
drop table if exists one_make_st.subj_oilstation;
create table if not exists one_make_st.subj_oilstation(sum_osnum bigint comment 油站数量,sumnew_osnum int comment 新增油站数量,dws_day string comment 日期维度-按天,dws_week string comment 日期维度-按周,dws_month string comment 日期维度-按月,oil_type string comment 油站维度-油站类型,oil_province string comment 油站维度-油站所属省,oil_city string comment 油站维度-油站所属市,oil_county string comment 油站维度-油站所属区,customer_classify string comment 客户维度-客户类型,customer_province string comment 客户维度-客户所属省
) comment 油站主题表
partitioned by (month String, week String, day String)
stored as orc
location /data/dw/st/one_make/subj_oilstation;构建 insert overwrite table one_make_st.subj_oilstation partition(month 202101, week2021W1, day20210101)
selectsum(oil.os_num) sum_osnum, --油站数量sum(oil.current_new_os_num) sumnew_osnum, --新增油站数量dd.date_id dws_day, --日期天dd.week_in_year_id dws_week, --日期周dd.year_month_id dws_month, --日期月dimoil.company_name oil_type, --油站类型dimoil.province_name oil_province, --油站省份dimoil.city_name oil_city, --油站城市dimoil.county_name oil_county, --油站区域dimoil.customer_classify_name customer_classify, --客户类型dimoil.customer_province_name customer_province --客户省份
--油站事务事实表
from one_make_dwb.fact_oil_station oil
--关联日期维度表
left join one_make_dws.dim_date dd on oil.dt dd.date_id
--关联油站维度表
left join one_make_dws.dim_oilstation dimoil on oil.os_id dimoil.id
where dd.year_month_id 202101and dd.week_in_year_id 2021W1 and dd.date_id 20210101
--按照维度字段分组
group by dd.date_id, dd.week_in_year_id, dd.year_month_id, dimoil.company_name, dimoil.province_name, dimoil.city_name, dimoil.county_name, dimoil.customer_classify_name, dimoil.customer_province_name;小结 实现油站主题表的维度指标构建