首页 > 其他分享 >10.4 第三问

10.4 第三问

时间:2022-10-04 18:23:52浏览次数:52  
标签:10.4 -- nbr sale day 第三 id String

(1)统计每天各个机场的销售数量和销售金额。要求的输出字段 day_id,sale_nbr,,cnt,round 日期编号,卖出方代码,数量,金额。

命令:

查询语句:

select day_id,sale_nbr,sum(cnt),sum(round) from sale where sale_nbr like 'C%' group by day_id,sale_nbr;

创建表table1:

create table table1(day_id String,sale_nbr String, cnt String,round String) ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

将查询语句保存至table1:

insert overwrite table table1 select day_id,sale_nbr,sum(cnt),sum(round) from sale where sale_nbr like 'C%' group by day_id,sale_nbr;

 

(2)统计每天各个代理商的销售数量和销售金额.要求的输出字段 day_id,sale_nbr,cnt,round 日期编号,卖出方代码,数量,金额

命令:

查询语句:

select day_id,sale_nbr,sum(cnt),sum(round) from sale where sale_nbr like 'O%' or buy_nbr like 'O%' group by day_id,sale_nbr;

创建表table2:

create table table2(day_id String,sale_nbr String, cnt String,round String) ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

将查询结果保存至table2:

insert overwrite table table2 select day_id,sale_nbr,sum(cnt),sum(round) from sale where sale_nbr like 'O%' or buy_nbr like 'O%' group by day_id,sale_nbr;

 

(3)统计每天各个代理商的销售活跃度。 要求的输出字段 day_id,sale_nbr, sale_number 日期编号,卖出方代码,交易次数(买入或者卖出均算交易次数)

 命令:

查询语句:

select day_id,sale_nbr,count(sale_nbr)from sale where sale_nbr like "O%" group by sale_nbr,day_id;

创建表table3:

create table table3(day_id String,sale_nbr String, sale_number String) ROW format delimited fields terminated by ',' STORED AS TEXTFILE;

将查询结果保存至表table3:

insert overwrite table table3 select day_id,sale_nbr,count(sale_nbr)from sale where sale_nbr like "O%" group by sale_nbr,day_id;

 

导入mysql:

1.建表(可视化建表):

2.sqoop路径下执行命令:

bin/sqoop export

> --connect jdbc:mysql://master:3306/mysql

> --username root

> --password 000000

> --table table1

> --num-mappers 1

> --export-dir /user/hive/warehouse/table1

> --input-fields-terminated-by ","

 

 

bin/sqoop export

> --connect jdbc:mysql://master:3306/mysql

> --username root

> --password 000000

> --table table2

> --num-mappers 1

> --export-dir /user/hive/warehouse/table2

> --input-fields-terminated-by ","

 

 

标签:10.4,--,nbr,sale,day,第三,id,String
From: https://www.cnblogs.com/lss1226/p/16754168.html

相关文章

  • 10.4训练
    输入schematool-initSchema-dbTypemysql-verbose初始化hive元数据库hive建表createtabletest0(day_idstring,sale_nbrstring,buy_nbrstring,cntint,roun......
  • 10.4
    bin/sqoopexport>--connectjdbc:mysql://master:3306/mysql>--usernameroot>--password000000>--tabletable3>--num-mappers1>--export-dir/user/hive/......
  • nginx&http 第三章 ngx http 框架处理流程
    1.nginx 连接结构 ngx_connection_t 这个连接表示是客户端主动发起的、Nginx服务器被动接受的TCP连接,我们可以简单称其为被动连接。同时,在有些请求的处理过程中,Nginx会试......
  • Python 入门指南第三节 | Python 简介
    3.Python简介下面的例子中,输入和输出分别由大于号和句号提示符(​​>>>​​​和​​...​​)标注:如果想重现这些例子,就要在解释器的提示符后,输入(提示符后面的)那些不包含......
  • 2022.10.4什么是计算机随笔
    什么是计算机冯诺依曼被称为计算机之父computer俗称电子计算机、电脑计算机分硬件和软件计算机广泛应用在人工智能、网络安全、科学计算、数据处理、自动......
  • 如何在Hue中集成第三方Web应用
    温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图。Fayson的github:​​https://github.com/fayson/cdhproject​​提示:代码块部分可......
  • 2022.10.4markdown随笔
    Markdowm学习标题三级标题四级标题 字体helloworldhelloworldhelloworldhelloworld引用选择坚持,留住明天!分割线图片超链接点击跳转到哔哩哔哩列表......
  • 社论 22.10.4
    Problem令\(\text{M}_n(\mathbb{F}_p)\)表示模\(p\)意义下全体\(n\)阶矩阵的集合。一个映射\(f:R\toR\)称为同态,当且仅当$$\forallX,Y\inR,f(X+Y)=f(X)......
  • 2022.10.4 - mac安装homebrew
    因为网络的问题,所以用国内源;有个大佬写好了自动下载脚本:https://gitee.com/cunkai/HomebrewCN按照文档选择镜像下载安装就OK;安装是安装好了,但是下载的时候会出现:Comman......
  • 极值的第二第三充分条件证明
    极值的第三充分条件若\(f'(x_0)=f''(x_0)=...=f^{(n-1)}(x_0)=0,f^n(x_0)\neq0,\)则当n为偶数时\(f(x_0)\)在\(x_0\)处有极值,其中\(f^{(n)}(x_0)>0\)时取得极小值,\(f......