Unique values with DISTINCT
DISTINCT removes duplicate result rows. With several columns, it removes duplicate combinations, not duplicates from each column independently. The table itself stays unchanged.
हिन्दी में समझें
DISTINCT परिणाम की दोहराई पंक्तियाँ हटाता है। कई कॉलम होने पर पूरी जोड़ी की तुलना होती है। मूल टेबल नहीं बदलती।
अभ्यास: उत्पाद की अलग-अलग category अक्षर क्रम में दिखाएँ।
Hinglish mein samjhein
DISTINCT result ki duplicate rows hatata hai. Multiple columns par poori combination compare hoti hai. Original table nahi badalti.
Practice: Unique product category alphabetical order mein dikhao.
A small SQL example
SELECT DISTINCT city FROM customers;Examples use the fictional shop database bundled with the SQL playground: customers, products, orders, order_items and employees. The engine is SQLite; other SQL dialects may differ.
Try this example in the SQL playground →Practise this idea
Show distinct product categories, ordered alphabetically.
Check answer & explanation
SELECT DISTINCT category FROM products ORDER BY category;DISTINCT removes repeated category rows. ORDER BY category makes the remaining categories alphabetical.
Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.
Check your understanding
DISTINCT removes…
Check the quiz answer
Duplicate result rows
DISTINCT removes duplicate result rows. With several columns, it removes duplicate combinations, not duplicates from each column independently. The table itself stays unchanged.
References & corrections
Use the official SQLite documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.