(1) 统计每天各个机场的销售数量和销售金额
首先创建一个存储该数据的表text3_1
Create table text3_1(day_id varchar(30), sale_nbr varchar(30), cnt varchar(30), round varchar(30)) row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES
(
"separatorChar"=","
)
STORED AS TEXTFILE;
然后将查询的数据存储到该表
insert overwrite table text3_1
SELECT
day_id,
sale_nbr,
SUM(cnt),
SUM(round)
FROM
test3
WHERE sale_nbr LIKE 'C%'
GROUP BY day_id,sale_nbr;
(2)统计每天各个代理商的销售数量和销售金额
首先创建一个存储该数据的表text3_2
Create table text3_2(day_id varchar(30), sale_nbr varchar(30), cnt varchar(30), round varchar(30)) row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES
(
"separatorChar"=","
)
STORED AS TEXTFILE;
然后将查询的数据存储到该表
insert overwrite table text3_2
SELECT
day_id,
sale_nbr,
SUM(cnt),
SUM(round)
FROM
test3
WHERE sale_nbr LIKE "O%"
GROUP BY day_id,sale_nbr;
(3)统计每天各个代理商的销售活跃度
首先创建一个存储该数据的表text3_3
Create table text3_3(day_id varchar(30), sale_nbr varchar(30), sale_number varchar(30)) row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES
(
"separatorChar"=","
)
STORED AS TEXTFILE;
然后将查询的数据存储到该表
insert overwrite table text3_3
SELECT
day_id,
sale_nbr,
COUNT(sale_nbr)
FROM
test3
WHERE sale_nbr LIKE "O%"
GROUP BY day_id,sale_nbr;