Search Header Logo

Mastering MySQL: HAVING and GROUP BY

Authored by Sayeda Habeeba

Computers

7th Grade

Used 2+ times

Mastering MySQL: HAVING and GROUP BY
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the `HAVING` clause in MySQL?

To filter rows before grouping them

To filter groups after aggregation

To sort the results

To join tables

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is an example of an aggregate function in MySQL?

`SELECT`

`WHERE`

`COUNT()`

`JOIN`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following SQL query: `SELECT department, COUNT(*) FROM employees GROUP BY department;`. What does this query do?

It counts the total number of employees

It counts the number of employees in each department

It lists all departments

It lists all employees

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which clause would you use to filter the results of a `GROUP BY` query based on an aggregate function?

`WHERE`

`ORDER BY`

`HAVING`

`LIMIT`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between `WHERE` and `HAVING` clauses in MySQL?

`WHERE` filters rows before aggregation, `HAVING` filters after

`WHERE` filters after aggregation, `HAVING` filters before

Both filter after aggregation

Both filter before aggregation

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following queries correctly uses `HAVING` with `GROUP BY` to find departments with more than 10 employees?

`SELECT department FROM employees WHERE COUNT(*) > 10 GROUP BY department;`

`SELECT department FROM employees GROUP BY department HAVING COUNT(*) > 10;`

`SELECT department FROM employees GROUP BY department WHERE COUNT(*) > 10;`

`SELECT department FROM employees HAVING COUNT(*) > 10 GROUP BY department;`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In the query `SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 50000;`, what does `AVG(salary) > 50000` do?

It filters departments with an average salary less than $50,000

It filters departments with an average salary greater than $50,000

It calculates the average salary for all employees

It lists all departments

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?