• 大数据课堂测试02——机场销售情况及代理商


    1、数据导入:

    要求将样表文件中的(sales_sample_20170310)数据导入 HIVE 数据仓库中。

     

    2、数据清洗:

    要求将 day_id 一列中的数值清洗为真实的日期格式,可用字符串表示。

    数据 1 对应日期 2021-09-01,依次类推,15 对应日期 2021-09-15

     

    insert overwrite table sales_clean select date_add('2021-09-00',cast(day_id as int)) as day_id,sale_nbar as sale_nbr,buy_nbr as buy_nbr,cnt as cnt,round as round from sales_result;

     

    3、数据分析处理:

    1)统计每天各个机场的销售数量和销售金额。

    要求的输出字段

    day_id,sale_nbr,,cnt,round

    日期编号,卖出方代码,数量,金额

    新建机场的销售表:sales_ariport2存储

    insert into sales_airport2(day_id,sale_nbr,cnt,round)select day_id, sale_nbr, SUM(cnt) as cnt,SUM(round) as round from sales_test2_clean group by sale_nbr,day_id having sale_nbr like 'C%';

    (2)统计每天各个代理商的销售数量和销售金额。

    要求的输出字段

    day_id,sale_nbr,,cnt,round

    日期编号,卖出方代码,数量,金额

    新建代理商表:sales_dailishang

    #代理商  

    create table sales_dailishang(day_id String,

                             sale_nbr String,

                             cnt int,

                             round int)

                             ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

    insert into sales_dailishang(day_id,sale_nbr,cnt,round)select day_id, sale_nbr, SUM(cnt) as cnt,SUM(round) as round from sales_test2_clean group by sale_nbr,day_id having sale_nbr like 'O%'; 

     

    3)统计每天各个代理商的销售活跃度。

    要求的输出字段

    day_id,sale_nbr, sale_number

    日期编号,卖出方代码,交易次数(买入或者卖出均算交易次数)

    代理商总表sales_dailishang_all

    create table sales_dailishang_all as select day_id as day_id,sale_nbr as sale_nbr,buy_nbr as buy_nbr,SUM(cnt) as cnt,SUM(round) as round from sales_clean group by sale_nbr,buy_nbr,day_id having sale_nbr like 'O%';

    代理商卖出表sales_dailishang_sale

    create table sales_dailishang_sale as select day_id as day_id,sale_nbr as sale_nbr,buy_nbr as buy_nbr,SUM(cnt) as cnt,SUM(round) as round from sales_clean group by sale_nbr,buy_nbr,day_id having sale_nbr like 'O%';

    代理商买入sales_dailishang_buy

    create table sales_dailishang_buy as select day_id as day_id,sale_nbr as sale_nbr,buy_nbr as buy_nbr,SUM(cnt) as cnt,SUM(round) as round from sales_clean group by sale_nbr,buy_nbr,day_id having buy_nbr like 'O%';

    代理商活跃度 sales_dailishang_active

    insert into sales_dailishang_active(day_id,sale_nbr,active)select day_id,sale_nbr,SUM(CNT) from sales_test2_clean group by sale_nbr,day_id having sale_nbr like 'O%';

    (4)汇总统计 9 月 1 日到 9 月 15 日之间各个代理商的销售利润。

    编号,卖出方代码,买入数量,买入金额,卖出数量,卖出金额,销售利润(卖出金额-买入金额)

    #卖出  

    create table sales_out(day_id String,

                             sale_nbr String,

                             cnt int,

                             round int)

                             ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

    #买入  

    create table sales_in(day_id String,

                             buy_nbr String,

                             cnt int,

                             round int)

                             ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

    #利润  

    create table sales_lirun(day_id String,

    sale_nbr String,

    incnt int,

    inround int,

    outcnt int,

    outround int,

    lirun int)

    ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

    (5)设计分析代理商的市场地位根据市场交易次数、交易对象个数、销售机票数量、销售利润等。(选做题)

     

     

    4、处理结果入库:

    将上述统计分析的结果数据保存到 mySQL 数据库中。

    (1)统计每天各个机场的销售数量和销售金额。

    (2)统计每天各个代理商的销售数量和销售金额。

    (3) 统计每天各个代理商的销售活跃度。

     

    (4)汇总统计 9 月 1 日到 9 月 15 日之间各个代理商的销售利润。

    5、数据可视化展示:

    利用 Echarts 将上述统计结果以图形化展示的方式展现出来:饼图、柱状图、地图、折线图等。

    (1)统计每天各个机场的销售数量和销售金额。

     

      (2)统计每天各个代理商的销售数量和销售金额。

     

     

    (3)统计每天各个代理商的销售活跃度。

     

     

    (3)汇总统计 9 月 1 日到 9 月 15 日之间各个代理商的销售利润。

     

  • 相关阅读:
    Python reportlab table 设置cellstyle枚举,设置单元格padding
    代理工具 v2ra*的使用
    python 开发环境需要安装
    postgres 新增或者更新语句
    python psycopg2 查询结果返回字典类型
    postgres 多个字段匹配查询
    django 执行原生sql形参传递,字段参数传递
    亚马逊接口调用
    python x 开头的字符转码为中文
    postgres 定义变量
  • 原文地址:https://www.cnblogs.com/Lizhichengweidashen/p/14904660.html
Copyright © 2020-2023  润新知