Junior
Mis on käsk DISTINCT ja milleks seda kasutatakse?
sobes.tech AI
Vastus AI-lt
The DISTINCT command in SQL is used to select only unique (non-repeating) values from a specified column or set of columns in the query results of SELECT.
Applications:
- Removing duplicates from query results.
- Getting a list of all unique values from a column (e.g., a list of all different cities, buyers, etc.).
Example of usage:
-- Select all unique cities from the "Customers" table
SELECT DISTINCT City
FROM Customers;
-- Select unique combinations of city and country from the "Customers" table
SELECT DISTINCT City, Country
FROM Customers;