MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:HAVING Clause
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, you can select values from a JSON column using the ->> operator.

Q2
True / False

In MySQL, the HAVING clause can only be used with aggregate functions such as COUNT, SUM, and AVG.

Q3
True / False

The HAVING clause can be used in combination with the WHERE clause in a MySQL query.

Q4
True / False

In MySQL, you can use HAVING with conditions on columns that are not aggregated.

Q5
True / False

You can use multiple conditions in the HAVING clause in MySQL, similar to the WHERE clause.

Q6
True / False

In MySQL, the HAVING clause can be used to filter rows that do not meet a condition specified in the GROUP BY clause.

Q7
True / False

The HAVING clause can be used to filter results based on the results of subqueries in MySQL.

Q8
True / False

In MySQL, the HAVING clause can be used with complex expressions, including subqueries and joins.

Q9
True / False

In a MySQL query, the HAVING clause is evaluated before the GROUP BY clause.

Q10
True / False

In MySQL, the HAVING clause is used to filter rows before grouping them.

Q11
Single Choice

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

Q12
Single Choice

Which of the following SQL statements correctly uses the HAVING clause to filter out groups with a sum less than 100?

Q13
Single Choice

Which of the following keywords is necessary for using the HAVING clause in MySQL?

Q14
Single Choice

Given the following query, what will be the output?

SQL Code
SELECT department_id, COUNT(*) AS total_employees
FROM employees
GROUP BY department_id
HAVING total_employees > 5;
Q15
Single Choice

Which of the following queries will display departments with an average salary greater than 5000?

Q16
Single Choice

Which of the following SQL queries will filter out the cities where the total number of orders is exactly 10?

Q17
Single Choice

Consider the following SQL query. What does it return?

SQL Code
SELECT department_id, MAX(salary)
FROM employees
GROUP BY department_id
HAVING MAX(salary) > ALL (SELECT MAX(salary) FROM employees WHERE department_id != 1);
Q18
Single Choice

How does the following query behave with the HAVING clause?

SQL Code
SELECT category, COUNT(*)
FROM products
GROUP BY category
HAVING COUNT(*) > 1 AND AVG(price) > 100;
Q19
Single Choice

What does the following SQL query return?

SQL Code
SELECT department_id, SUM(salary)
FROM employees
GROUP BY department_id
HAVING SUM(salary) BETWEEN 20000 AND 50000
ORDER BY SUM(salary) DESC;
Q20
Single Choice

Which of the following queries correctly filters out departments where the number of employees is less than the average number of employees across all departments?

Q21
Multiple Choice

Which query groups the records in the 'employees' table by 'department_id' and filters the groups to include only those with an average salary greater than 50000?

SQL Code
SELECT department_id, AVG(salary) AS avg_salary
FROM employees
GROUP BY department_id
HAVING AVG(salary) > 50000;
Q22
Multiple Choice

Identify the correct SQL query that groups records in the 'orders' table by 'order_date' and filters the groups to include only those with more than 10 orders.

SQL Code
SELECT order_date, COUNT(order_id) AS order_count
FROM orders
GROUP BY order_date
HAVING COUNT(order_id) > 10;
Q23
Multiple Choice

Which query groups records in the 'products' table by 'category_id' and filters the groups to include only those with a total price greater than 1000?

SQL Code
SELECT category_id, SUM(price) AS total_price
FROM products
GROUP BY category_id
HAVING SUM(price) > 1000;
Q24
Multiple Choice

Determine the correct SQL query that groups records in the 'customers' table by 'country' and filters the groups to include only those with maximum revenue greater than 100000.

SQL Code
SELECT country, MAX(revenue) AS max_revenue
FROM customers
GROUP BY country
HAVING MAX(revenue) > 100000;
Q25
Multiple Choice

Which SQL query groups records in the 'inventory' table by 'item_code' and filters the groups to include only those with more than 5 distinct locations?

SQL Code
SELECT item_code, COUNT(DISTINCT location) AS location_count
FROM inventory
GROUP BY item_code
HAVING COUNT(DISTINCT location) > 5;
Q26
Multiple Choice

Which query correctly groups records in the 'sales' table by 'sales_rep' and filters the groups to include only those with total sales greater than 200000?

SQL Code
SELECT sales_rep, SUM(sales_amount) AS total_sales
FROM sales
GROUP BY sales_rep
HAVING SUM(sales_amount) > 200000;
Q27
Multiple Choice

Determine the correct SQL query that groups records in the 'transactions' table by 'transaction_date' and filters the groups to include only those with average transaction amount greater than 1000.

SQL Code
SELECT transaction_date, AVG(transaction_amount) AS avg_amount
FROM transactions
GROUP BY transaction_date
HAVING AVG(transaction_amount) > 1000;
Q28
Multiple Choice

Which SQL query groups records in the 'projects' table by 'project_manager' and filters the groups to include only those with minimum budget less than 50000?

SQL Code
SELECT project_manager, MIN(budget) AS min_budget
FROM projects
GROUP BY project_manager
HAVING MIN(budget) < 50000;
Q29
Multiple Choice

Identify the correct query that groups records in the 'clients' table by 'region' and filters the groups to include only those with distinct client count greater than 50.

SQL Code
SELECT region, COUNT(DISTINCT client_id) AS client_count
FROM clients
GROUP BY region
HAVING COUNT(DISTINCT client_id) > 50;
Q30
Multiple Choice

Which SQL query correctly groups records in the 'students' table by 'grade' and filters the groups to include only those with more than 100 students?

SQL Code
SELECT grade, COUNT(student_id) AS total_students
FROM students
GROUP BY grade
HAVING COUNT(student_id) > 100;