Interview Question

What is DISTINCT keyword?

DISTINCT keeps one copy of each distinct selected row.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

DISTINCT removes duplicate result rows from a SELECT result. • Duplicate comparison applies to the complete selected row. • DISTINCT is processed before the final ORDER BY result is returned. • It should not replace correct join conditions or data constraints.

💡 SQL Example

SELECT DISTINCT department_id FROM employees ORDER BY department_id;

Result

10 20

⚡ Quick Revision

DISTINCT keeps one copy of each distinct selected row.