![]() |
![]() |
![]() |
The SELECT DISTINCT Clause is used to fetch distinct values in a specific column of a given table.
This is Part 3 of 40 Part SQL Server T-SQL Tutorial. Click here to read it from the beginning….
SELECT DISTINCT Syntax – SQL Server SELECT DISTINCT Statement
Use <DatabaseName>
GO
SELECT DISTINCT (column1)
FROM schema.table
GO
SQL Server SELECT DISTINCT Statement: How to Query Distinct Records from a Table in SQL Server
SELECT DISTINCT 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

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