What is the DISTINCT statement and how do use it
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mukesh SagarRank #640 · 3.8K reputationPosted Aug 3, 2025, 1:48 AM EDT
DISTINCT keyword is used to get the unique values from a database table. The syntax for the same is :
Select distinct deptno from emp;
Using this statement we get the unique department numbers avialable.
Cynthia SathuragiriRank #937 · 2.2K reputationPosted Aug 4, 2025, 1:52 AM EDT
DISTINCTgives you only unique values, removing any duplicates.DISTINCThelps you get only one entry for each unique combination of selected columns.SELECT DISTINCT column1, column2, ...
FROM table_name
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 4, 2025, 11:45 PM EDT
Hi Kiran,
The
DISTINCTstatement in SQL is used to retrieve only unique values from a query, filtering out any duplicate entries. It is typically used with theSELECTstatement to ensure that the result set contains only distinct rows.SELECT DISTINCT name FROM employees;