![]() |
![]() |
![]() |
The SELECT DISTINCT Statement is used to fetch distinct values in a specific column of a given table. This article gives you an overview of the SQL Server SELECT DISTINCT clause or SELECT DISTINCT SQL Clause.
This is Part 3 of 40 Part SQL Server T-SQL Tutorial. Click here to read it from the beginning….
SQL SELECT DISTINCT Statement
The SQL DISTINCT clause removes duplicates from the result set of a SELECT statement in SQL Server.
SELECT DISTINCT Syntax | SQL Server SELECT DISTINCT Statement
Use <DatabaseName>
GO
SELECT DISTINCT (column1)
FROM schema.table
GO
Note: To fetch unique records from a SQL Server Database Table, one needs to use DISTINCT SQL Keyword.
SQL Server SELECT DISTINCT Statement: How to Query Distinct Records from a Table in SQL Server
SELECT DISTINCT Clause Example
Execute the below query will fetch all Distinct First Name’s (Column FirstName) from Person table.
Use AdventureWorks2016
GO
SELECT
DISTINCT FirstName
FROM Person.Person
GO

When you need to SELECT UNIQUE records from a SQL Server Database Table, one needs to use SELECT DISTINCT in the SQL Server.
SELECT DISTINCT Multiple Columns Example
Execute the below query will fetch all the records which are distinct for FirstName and LastName from Person’s table.
Use AdventureWorks2016
GO
SELECT
DISTINCT FirstName
, LastName
FROM Person.Person
GO

Click Next Page button to continue reading the topics and click on the Previous Page button to revisit the previous topic.
Add comment