English 中文(简体)
Impala - Distinct Operator
  • 时间:2024-12-22

Impala - Distinct Operator


Previous Page Next Page  

The distinct operator in Impala is used to get the unique values by removing duppcates.

Syntax

Following is the syntax of the distinct operator.

select distinct columns… from table_name;

Example

Assume that we have a table named customers in Impala and its contents are as follows −

[quickstart.cloudera:21000] > select distinct id, name, age, salary from customers; 
Query: select distinct id, name, age, salary from customers

Here you can observe the salary of the customers Ramesh and Chaitap entered twice and using the distinct operator, we can select the unique values as shown below.

[quickstart.cloudera:21000] > select distinct name, age, address from customers;

On executing, the above query gives the following output.

Query: select distinct id, name from customers
+----------+-----+-----------+ 
| name     | age | address   | 
+----------+-----+-----------+ 
| Ramesh   | 32  | Ahmedabad |
| Khilan   | 25  | Delhi     | 
| kaushik  | 23  | Kota      | 
| Chaitap | 25  | Mumbai    |
| Hardik   | 27  | Bhopal    |
| Komal    | 22  | MP        | 
+----------+-----+-----------+
Fetched 9 row(s) in 1.46s
Advertisements