- Executores
-
Aprender
Aprender Python Exemplos executáveis, NumPy, pandas e mais Aprender IA / Machine LearningRedes neurais, ML e LLMs do zero Aprender C e C++ Ponteiros, memória, STL e C++ moderno Aprender C#Fundamentos, POO, LINQ, async e exercícios .NET Aprender MatplotlibGráficos de linha, barras, dispersão e pizza com visualizadores Aprender RustOwnership, traits, tratamento de erros e threads Aprender GoSlices, interfaces, goroutines e channels Algoritmos em Python Busca, ordenação, recursão e visualizações O(n) Algoritmos em C e C++ Compare implementações em C e C++ Programação para crianças Aprenda a programar brincando!
- QuizzesNovo
- DesafiosNovo
- Para professoresNovo
- Atualizações
- Me pague um café
Quiz de SQL: Join Pitfalls
This SQL quiz collects the join mistakes that produce wrong numbers without any error. You will see a LEFT JOIN turned into an inner join by WHERE, totals multiplied by fan-out, NULL keys that never match and other traps that show up in real reports and interviews.
Pergunta de exemplo
Pergunta 1 de 10The goal is every customer, with their big orders if any. What does this print?
CREATE TABLE customers (id INTEGER, name TEXT);
CREATE TABLE orders (id INTEGER, customer_id INTEGER, amount INTEGER);
INSERT INTO customers VALUES (1, 'Ann'), (2, 'Bob'), (3, 'Cy');
INSERT INTO orders VALUES (10, 1, 10), (11, 1, 50), (12, 3, 5);
SELECT c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.amount > 20
ORDER BY c.name;
Mostrar a resposta
A. Ann WHERE runs after the join, and for Bob o.amount is NULL, so NULL > 20 is not true and his row is dropped (Cy's 5 fails too). A condition on the right table in WHERE turns the left join into an inner join.
O que este quiz cobre
- Filtering a LEFT JOIN in
WHEREvs inON - Fan-out when joining two one-to-many tables
- Why NULL keys never match
- A later INNER JOIN undoing a LEFT JOIN
SUM(DISTINCT)and duplicate rows
Perguntas frequentes
Preciso de uma conta?
Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.
Posso refazer?
Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.