SQL Server Articles, Tips, FAQs, Reviews, Whitepaper, News etc - MyTechMantra.com

SQL Server SELECT DISTINCT Clause T-SQL Tutorial with Examples

Previous Page.. Begin Tutorial.. Next Page..

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 Records from a Table in 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
SELECT DISTINCT Multiple Columns Records from a Table in SQL Server

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

Previous Page.. Begin Tutorial.. Next Page..

Related T-SQL Tutorials

Ashish Mehta

Ashish Mehta

Ashish Kumar Mehta is a database manager, trainer and technical author. He has more than a decade of IT experience in database administration, performance tuning, database development and technical training on Microsoft SQL Server from SQL Server 2000 to SQL Server 2014. Ashish has authored more than 325 technical articles on SQL Server across leading SQL Server technology portals. Over the last few years, he has also developed and delivered many successful projects in database infrastructure; data warehouse and business intelligence; database migration; and upgrade projects for companies such as Hewlett-Packard, Microsoft, Cognizant and Centrica PLC, UK. He holds an engineering degree in computer science and industry standard certifications from Microsoft including MCITP Database Administrator 2005/2008, MCDBA SQL Server 2000 and MCTS .NET Framework 2.0 Web Applications.

Add comment

Newsletter Signup! Join 15,000+ Professionals




Be Social! Like & Follow Us...

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Recent SQL Server Tips