Квиз по SQL: 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.

Средний 10 вопроса ~6 минуты Проходной балл: 80% SQLite

Выберите режим

Вы играете как гость: войдите, чтобы сохранить XP и серию.

Пример вопроса

Вопрос 1 из 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;
Показать ответ

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.

Что проверяет этот квиз

  • 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

Частые вопросы

Нужен ли аккаунт?

Нет. Играть может любой. Войдите, чтобы сохранять XP, серию, значки и историю.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.