How To Select Distinct Records in SQL Server
A distinct keyword is used to retrieve distinct records from a table. Distinct keyword is used with the select statement and eliminate the duplicate records and retrieve the unique records. There is a possibility of duplicate records in your database table, while you need to fetch only unique records the distinct keyword is used.
DISTINCT keyword can also be used with aggregate functions like SUM, AVG, MIN, MAX etc.
SQL SELECT DISTINCT Demo
For this demo, first we create a table tblEmployee and insert some records.
Let’s insert some records.
Let’s insert some duplicate records.
Now, Select Distinct records from the table.
SELECT DISTINCT EmpFirstName FROM tblEmployee