mirror of
https://github.com/apache/impala.git
synced 2026-01-05 21:00:54 -05:00
This now gives a clean RAT check with bin/check-rat-report.py, which is one way for the Impala community to check compliance with ASF rules on intellectual property. Change-Id: I2ad06435f84a65ba126759e42a18fdaf52cd7036 Reviewed-on: http://gerrit.cloudera.org:8080/5232 Reviewed-by: Jim Apple <jbapple-impala@apache.org> Tested-by: Impala Public Jenkins Reviewed-by: John Russell <jrussell@cloudera.com>
80 lines
3.2 KiB
XML
80 lines
3.2 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
-->
|
|
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
|
|
<concept id="distinct">
|
|
|
|
<title>DISTINCT Operator</title>
|
|
<prolog>
|
|
<metadata>
|
|
<data name="Category" value="Impala"/>
|
|
<data name="Category" value="SQL"/>
|
|
<data name="Category" value="Querying"/>
|
|
<data name="Category" value="Aggregate Functions"/>
|
|
<data name="Category" value="Developers"/>
|
|
<data name="Category" value="Data Analysts"/>
|
|
</metadata>
|
|
</prolog>
|
|
|
|
<conbody>
|
|
|
|
<p>
|
|
<indexterm audience="Cloudera">DISTINCT operator</indexterm>
|
|
The <codeph>DISTINCT</codeph> operator in a <codeph>SELECT</codeph> statement filters the result set to
|
|
remove duplicates:
|
|
</p>
|
|
|
|
<codeblock>-- Returns the unique values from one column.
|
|
-- NULL is included in the set of values if any rows have a NULL in this column.
|
|
select distinct c_birth_country from customer;
|
|
-- Returns the unique combinations of values from multiple columns.
|
|
select distinct c_salutation, c_last_name from customer;</codeblock>
|
|
|
|
<p>
|
|
You can use <codeph>DISTINCT</codeph> in combination with an aggregation function, typically
|
|
<codeph>COUNT()</codeph>, to find how many different values a column contains:
|
|
</p>
|
|
|
|
<codeblock>-- Counts the unique values from one column.
|
|
-- NULL is not included as a distinct value in the count.
|
|
select count(distinct c_birth_country) from customer;
|
|
-- Counts the unique combinations of values from multiple columns.
|
|
select count(distinct c_salutation, c_last_name) from customer;</codeblock>
|
|
|
|
<p>
|
|
One construct that Impala SQL does <i>not</i> support is using <codeph>DISTINCT</codeph> in more than one
|
|
aggregation function in the same query. For example, you could not have a single query with both
|
|
<codeph>COUNT(DISTINCT c_first_name)</codeph> and <codeph>COUNT(DISTINCT c_last_name)</codeph> in the
|
|
<codeph>SELECT</codeph> list.
|
|
</p>
|
|
|
|
<p conref="../shared/impala_common.xml#common/zero_length_strings"/>
|
|
|
|
<note conref="../shared/impala_common.xml#common/multiple_count_distinct"/>
|
|
|
|
<note>
|
|
<p>
|
|
In contrast with some database systems that always return <codeph>DISTINCT</codeph> values in sorted order,
|
|
Impala does not do any ordering of <codeph>DISTINCT</codeph> values. Always include an <codeph>ORDER
|
|
BY</codeph> clause if you need the values in alphabetical or numeric sorted order.
|
|
</p>
|
|
</note>
|
|
</conbody>
|
|
</concept>
|