SQL stands for Structured Query Language. It is used to store, manipulate, and retrieve data present in a database server. We use the DISTINCT keyword in SQL with a SELECT statement to remove the duplicate records and return unique records. In this article, we will explore and understand the DISTINCT keyword. 

SQL DISTINCT Keyword

The DISTINCT keyword in SQL is used to fetch unique records and eliminates the duplicate records in the table. 

Syntax:

SELECT DISTINCT column1, column2,.....columnN 

FROM table_name

WHERE [condition]

Become The Highest-Paid Business Analysis Expert

With Business Analyst Master's ProgramExplore Now
Become The Highest-Paid Business Analysis Expert

Example:

Consider the table titled CUSTOMERS” with the records below;

data

The following SQL statement selects only the DISTINCT values from the ‘city’ column:

distinct

This will produce the following result:

output-distinct

Let’s look at one more example:

ex-sql-distinct

This will produce the count of different cities in the ‘customers’ table.

output-sql-distinct

You can also select multiple columns to get unique results from them.

distinct-mutiple

output-distinct-multiple

Gain expertise in the latest Business analytics tools and techniques with the Post Graduate Program in Business Analysis. Enroll now!

Next Steps

Now that you know about the SQL DISTINCT keyword, it’s time for you to take the next step. This is an essential step to moving forward in your journey to becoming an SQL expert. If you found this article beneficial and want to get certified, check out Simplilearn’s Business Analyst Master’s Program. This comprehensive program covers SQL in-depth. Upon completion you can earn your certification in this field can jumpstart your career. 

Do you have any questions for us? Feel free to place them in the comments section of this article. We’ll get our subject experts to answer them for you ASAP.

Our Software Development Courses Duration And Fees

Software Development Course typically range from a few weeks to several months, with fees varying based on program and institution.

Program NameDurationFees
Caltech Coding Bootcamp

Cohort Starts: 16 Dec, 2024

6 Months$ 8,000
Automation Test Engineer Masters Program

Cohort Starts: 27 Nov, 2024

8 months$ 1,499
Full Stack Java Developer Masters Program

Cohort Starts: 18 Dec, 2024

7 months$ 1,449
Full Stack (MERN Stack) Developer Masters Program

Cohort Starts: 8 Jan, 2025

6 Months$ 1,449