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 15:04:31 浏览: 46
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;
```
相关问题
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、按照部门分组,按照工资降序排序,显示员工姓名和工资。
```
SELECT staff_name, staff_salary
FROM employess41_table
WHERE staff_dept != ""
ORDER BY staff_dept, staff_salary DESC;
```
4、按照部门分组,按照工资降序排序,显示员工姓名、工资和部门。
```
SELECT staff_name, staff_salary, staff_dept
FROM employess41_table
WHERE staff_dept != ""
ORDER BY staff_dept, staff_salary DESC;
```
hive中values__tmp__table__1
在Hive中,`values__tmp__table__1`通常表示一个临时表,用于存储VALUES子句中的临时数据。这种表通常用于在查询中使用硬编码的常量值,而不是从其他表中检索数据。临时表的命名通常是自动生成的,以确保唯一性。在Hive中,这些临时表的命名约定通常是以`values__tmp__table__`开头,后面跟着一个数字或其他唯一标识符。