Impala - 不同的运营商

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