blog post

SELECT DISTINCT returns only distinct (different) values.
SELECT DISTINCT eliminates duplicate records from the results.
DISTINCT can be used with aggregates: COUNT, AVG, MAX, etc.
DISTINCT operates on a single column. DISTINCT for multiple columns is not supported.

The SQL SELECT DISTINCT syntax

The general syntax is:
SELECT DISTINCT column-name
  FROM table-name

Can be used with COUNT and other aggregates
SELECT COUNT (DISTINCT column-name)
  FROM table-name

SQL SELECT Examples

Problem: List all supplier countries in alphabetical order.
SELECT DISTINCT Country
  FROM Supplier
ORDER BY COUNTRY

Problem: List the number of supplier countries
SELECT COUNT (DISTINCT Country)
  FROM Supplier

  • Share This Story


Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla


I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Leave a comment

Name
E-mail
Url
Message

Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email

 

Style Switcher

Change Color

×! We use cookies to improve your user experience. More information