SQL DISTINCT Clause

The SQL DISTINCT clause is also used in the SELECT statement, it is used to get the data and display the unique values, and the values will be shown no matter how many times they appear in the table.

DISTINCT Syntax

SELECT DISTINCT columnname FROM tablename

Users:

Firstname Lastname Age Maritalstatus Country
Mathew Simon 30 Married UK
Bill Steve 20 Single Usa
Steve Hills 30 Single france
SELECT DISTINCT Age FROM Users

Users:

Age
30
20

DISTINCT Clause and GROUP BY Clause are by far having the same function. You can select whatever you feel you are comfortable with it.

Add new comment