hive sql 查询
时间: 2023-11-01 14:08:00 浏览: 78
Hive是基于Hadoop的数据仓库工具,可以通过HiveQL编写SQL语句来查询Hadoop中的数据。以下是一些Hive SQL查询的示例:
1. 查询表中的所有数据
```
SELECT * FROM table_name;
```
2. 查询表中的部分数据
```
SELECT column1, column2 FROM table_name WHERE condition;
```
3. 聚合函数查询
```
SELECT COUNT(*) FROM table_name;
SELECT MAX(column_name) FROM table_name;
SELECT MIN(column_name) FROM table_name;
SELECT SUM(column_name) FROM table_name;
SELECT AVG(column_name) FROM table_name;
```
4. 分组查询
```
SELECT column1, COUNT(*) FROM table_name GROUP BY column1;
```
5. 连接查询
```
SELECT table1.column1, table2.column2 FROM table1 JOIN table2 ON table1.key = table2.key;
```
6. 子查询
```
SELECT * FROM table1 WHERE column1 IN (SELECT column1 FROM table2 WHERE condition);
```
以上是一些常用的Hive SQL查询示例,具体查询语句可以根据具体业务需求进行编写。
阅读全文