SQL Quiz: LEFT JOIN

This SQL quiz is about LEFT JOIN and the NULLs it brings with it. You will count matches without losing unmatched rows, find rows that have no partner and see how COUNT, SUM and table order behave with outer joins.

मीडियम 10 सवाल ~6 मिनट पास होने के लिए 80% SQLite

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

CREATE TABLE customers (id INTEGER, name TEXT);
CREATE TABLE orders (id INTEGER, customer_id INTEGER);
INSERT INTO customers VALUES (1, 'Ann'), (2, 'Bob'), (3, 'Cy');
INSERT INTO orders VALUES (10, 1), (11, 1), (12, 3);
SELECT c.name, COUNT(o.id)
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
GROUP BY c.id, c.name
ORDER BY c.name;
जवाब दिखाएं

C. Ann|2 Bob|0 Cy|1 The left join keeps Bob with NULL order columns. COUNT(o.id) skips NULLs, so Bob's count is 0, which is exactly what you want for "orders per customer".

इस क्विज़ में क्या है

  • Keeping unmatched rows from the left table
  • COUNT(*) vs COUNT(column) after a LEFT JOIN
  • Finding rows with no match using IS NULL
  • NULL sums and COALESCE
  • RIGHT and FULL OUTER JOIN in SQLite, MySQL and PostgreSQL

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।