Impala教程

Impala Distinct

Impala 中的 distinct 运算符用于通过删除重复项来获取唯一值。

语法

以下是 distinct 运算符的语法。
select distinct columns… from table_name;

示例

假设我们在 Impala 中有一个名为 customers 的表,其内容如下-
[quickstart.cloudera:21000] > select distinct id, name, age, salary from customers; 
Query: select distinct id, name, age, salary from customers
在这里您可以观察输入两次的客户 Ramesh 和 Chaitali 的工资,并使用 distinct 运算符,我们可以选择如下所示的唯一值。
[quickstart.cloudera:21000] > select distinct name, age, address from customers;
执行时,上述查询给出以下输出。
Query: select distinct id, name from customers
+----------+-----+-----------+ 
| name     | age | address   | 
+----------+-----+-----------+ 
| Ramesh   | 32  | Ahmedabad |
| Khilan   | 25  | Delhi     | 
| kaushik  | 23  | Kota      | 
| Chaitali | 25  | Mumbai    |
| Hardik   | 27  | Bhopal    |
| Komal    | 22  | MP        | 
+----------+-----+-----------+
Fetched 9 row(s) in 1.46s
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4