hive 分组+排序 1、创建外部表employess41_table,表名中加上座位号 CREATE EXTERNAL TABLE IF NOT EXISTS employess01_table( staff_name STRING, staff_age INT, staff_salary FLOAT, late_deduction FLOAT, staff_dept STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' STORED AS textfile LOCATION '/hive'; 2、将下列数据使用基本插入方式插入到表中,并查看表中数据。 insert into table employess41_table values ("Lilith Hardy",30,6000,50,"Finance Department"), ("Byron Green",36,5000,25,"Personnel Department"), ("Yvette Ward",21,4500,15.5,""), ("Arlen Esther",28,8000,20,"Finance Department"), ("Rupert Gold",39,10000,66,"R&D Department"), ("Deborah Madge",41,6500,0,"R&D Department"), ("Tim Springhall",22,6000,36.5,"R&D Department"), ("Olga Belloc",36,5600,10,"Sales Department"), ("Bruno Wallis",43,6700,0,"Personnel Department"), ("Flora Dan",27,4000,35,"Sales Department"); 3、获取部门R&D Department中薪资大于8000的员工信息。 4、查询员工信息表employess_table的部门信息。 5、查询同一部门的工资总数。 6、查询同一部门的平均年龄。
时间: 2023-07-19 10:04:31 浏览: 129
Hive管理表和外部表的区别
3、获取部门R&D Department中薪资大于8000的员工信息。
```
SELECT staff_name, staff_age, staff_salary, late_deduction, staff_dept
FROM employess01_table
WHERE staff_dept = 'R&D Department' AND staff_salary > 8000;
```
4、查询员工信息表employess_table的部门信息。
```
SELECT DISTINCT staff_dept
FROM employess01_table;
```
5、查询同一部门的工资总数。
```
SELECT staff_dept, SUM(staff_salary)
FROM employess01_table
GROUP BY staff_dept;
```
6、查询同一部门的平均年龄。
```
SELECT staff_dept, AVG(staff_age)
FROM employess01_table
GROUP BY staff_dept;
```
阅读全文