Documentation Index
Fetch the complete documentation index at: https://docs.oxla.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
When using aggregation functions, they can contain theDISTINCT keyword. It acts as a qualifier for them, to ensure that only unique values are being processed. Here’s how a sample syntax looks like:
DISTINCT keyword can be combined with the following aggregate functions:
AVG()COUNT()MAX()MIN()SUM()
DISTINCT keyword.
Examples
In this section we’ll focus on a few examples, that showcase sample usage of the above mentioned concepts. They will be based on creation of the following tables:DISTINCT combined with COUNT function
The following example uses DISTINCT qualifier combined with COUNT() function to calculate the number of unique car brands in rentals:
DISTINCT qualifier combined with COUNT() function to calculate the amount of rentals by each customer:
rental_count by each customer_name as shown below:
DISTINCT combined with MAX() function
The following example uses DISTINCT qualifier combined with MAX() function to find maximum single spending per each customer, dropping any repeated transactions:
DISTINCT combined with SUM() function
The following example compares the sum of unique revenues versus the sum of all revenues in rental data:
Limitations
There is one usecase we are aware of but do not support currently:- Aggregation functions with
DISTINCTkeyword used as an argument of an expression, e.g.