What is DISTINCT and what is good for?
Experience Level: Junior
Tags: DatabasesMS SQL ServerQuality Assurance (QA)
Answer
DISTINCT keyword is used in conjunction with SELECT keyword to return unique values only instead of returning all values.
SELECT DISTINCT FirstName FROM Customers
The query above will return all unique first names from table Customers.
Related Databases job interview questions
What is ORDER BY statement used for in Microsoft SQL server?
DatabasesMS SQL ServerQuality Assurance (QA) JuniorWhat is WHERE statement good for in SQL server script?
DatabasesMS SQL ServerQuality Assurance (QA) JuniorWhat is TOP and what is it good for in SQL server script?
DatabasesQuality Assurance (QA) JuniorUsing SQL query, how do you limit number of returned rows using TOP(x)?
DatabasesMS SQL ServerQuality Assurance (QA) JuniorHow can you select rows from the database table using a script using SELECT?
DatabasesQuality Assurance (QA) Junior