SQL-Quiz: HAVING

This SQL quiz is about HAVING, the filter that runs after rows are grouped. You will predict which groups survive, combine WHERE and HAVING in one query and learn when to use which.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% SQLite

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this query return?

CREATE TABLE sales (region TEXT, rep TEXT, amount INTEGER);
INSERT INTO sales VALUES ('North', 'Ana', 100), ('South', 'Ben', 200), ('North', 'Cy', 50), ('South', 'Ana', 70), ('East', 'Dee', 30);
SELECT region FROM sales GROUP BY region HAVING SUM(amount) > 100 ORDER BY region;
Lösung zeigen

B. North South The totals are East 30, North 150 and South 270. HAVING keeps only groups whose total is over 100: North and South. Note that North passes even though none of its single rows is over 100.

Darum geht es in diesem Quiz

  • Filtering groups with HAVING
  • WHERE (rows, before grouping) vs HAVING (groups, after)
  • Using WHERE and HAVING in the same query
  • Conditions on aggregates that are not in the SELECT list
  • Portable HAVING without column aliases

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.