codecamp

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

impala with子句
impala 相关资源
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }