DISTINCT
DISTINCT is a keyword in SQL that is used to remove duplicates in the result set of a SELECT statement. It only allows unique values to be returned, ensuring the elimination of any duplicate entries.
Example
Output
Explanation
The DISTINCT
keyword in SQL is used to return only distinct (unique) values. In the example above, SELECT DISTINCT country FROM customers
returns only unique country names from the ‘customers’ table.
Example
Output
Explanation
DISTINCT
keyword in SQL is used to return unique values in the output. It removes all the duplicate records and only shows distinct (unique) records. In the provided example, unique values from the specified column in the table are returned.
Example
Output
Explanation
The DISTINCT keyword is used in SELECT statements to return unique values in the output. In the example above, the SQL returns only unique last names from the “Employees” table.
Example
Output
Explanation
In the provided example, the SELECT DISTINCT
statement is used to return unique department IDs from the ‘employees’ table, thus eliminating duplicate entries. The result is a list of distinct or unique ‘department_id’s.
Example
Output
Explanation
The DISTINCT keyword in SQL is used to return only distinct (different) values. In the example above, from the ‘Customers’ table, it returns all distinct countries present in the ‘Country’ column.