Hi friends, in this post we will learn about SQL Distinct. Distinct keyword is used to get distinct (different) values. SQL DISTINCT keyword is used in with SELECT statement, it eliminate all the duplicate records and fetching only unique records.
Earlier we had discussed about SQL Group by Clause,SQL Order By Clause,SQL Select Top Clause, Like Clause SQL Server, SQL AND & OR Operators, SQL Where Clause, Delete Query SQL Server, SQL Update Statement, SQL Select Statement, SQL Insert Statement, Drop Table SQL Server, Rename Table in SQL Server, Create Table SQL Server, Schema In SQL Server, SQL Server Operators, Data Type in SQL Server and Drop-Delete SQL Server Database Using Management Studio or Query.
Table Structure :
SQL Server Distinct Query:
In below queries, query with DISTINCT gives you only 5 records, as it eliminate duplicate records, while second query gives you 7 records.
----SELECT DATABASE---- USE HIGHTECHNOLOGY GO ----DISTINCT EXAMPLES---- SELECT DISTINCT ADDRESS FROM EMPLOYEE GO ----ALL RECORDS---- SELECT ADDRESS FROM EMPLOYEE GO