MySQL Database Quiz Questions

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

The COUNT function in MySQL can only be used with numeric columns.

Q2
True / False

The SUM function in MySQL ignores NULL values in the column.

Q3
True / False

In MySQL, the AVG function always returns an integer value.

Q4
True / False

The MIN and MAX functions in MySQL can be used with date columns.

Q5
True / False

MySQL, using the COUNT function with a specific column name will count only the non-NULL values of that column.

Q6
True / False

The SUM function in MySQL can be used to add up the values of a string column.

Q7
True / False

In MySQL, the AVG function will return NULL if all values in the column are NULL.

Q8
True / False

MySQL’s COUNT function can be used with the DISTINCT keyword to count unique values.

Q9
True / False

The MIN and MAX functions in MySQL can be used in the same query to find the range of values in a numeric column.

Q10
True / False

In MySQL, the SUM and AVG functions can be used together in a single query to calculate both the total and average of a numeric column.

Q11
Single Choice

Which of the following SQL clauses can be used to filter groups based on the result of the COUNT function?

SQL Code
SELECT department, COUNT(*)
FROM employees
GROUP BY department
___ COUNT(*) > 5;
Q12
Single Choice

In MySQL, how would you filter groups of products to show only those with an average price greater than 100?

SQL Code
SELECT category, AVG(price)
FROM products
GROUP BY category
HAVING AVG(price) > ___;
Q13
Single Choice

Which MySQL function can be used with the HAVING clause to find the minimum salary in a group of departments?

SQL Code
SELECT department, MIN(salary)
FROM employees
GROUP BY department
HAVING MIN(salary) > 30000;
Q14
Single Choice

You want to find all departments where the total salary exceeds $500,000. Which SQL code correctly implements this using a HAVING clause?

SQL Code
SELECT department, SUM(salary)
FROM employees
GROUP BY department
HAVING SUM(salary) > ___;
Q15
Single Choice

Which of the following SQL queries will correctly return categories with a maximum price greater than $200?

SQL Code
SELECT category, MAX(price)
FROM products
GROUP BY category
HAVING ___ > 200;
Q16
Single Choice

What will the following SQL code return?

SQL Code
SELECT manager_id, AVG(salary)
FROM employees
GROUP BY manager_id
HAVING AVG(salary) < 80000;
Q17
Single Choice

How do you filter out departments where the minimum employee salary is exactly $50,000 using the HAVING clause

SQL Code
SELECT department, MIN(salary)
FROM employees
GROUP BY department
HAVING MIN(salary) <> 50000;
Q18
Single Choice

Which of the following queries shows departments with at least one employee having a salary greater than the average salary of that department?

SQL Code
SELECT department
FROM employees
GROUP BY department
HAVING MAX(salary) > AVG(salary);
Q19
Single Choice

Which SQL statement will find products in categories where the total sales amount exceeds the maximum single sale?

SQL Code
SELECT category
FROM sales
GROUP BY category
HAVING SUM(amount) > MAX(amount);
Q20
Single Choice

Which of the following statements is true regarding the HAVING clause when used with aggregate functions in MySQL?

Q21
Multiple Choice

Which query uses the COUNT function to find the total number of orders in the 'orders' table?

SQL Code
SELECT COUNT(order_id) AS total_orders
FROM orders;
Q22
Multiple Choice

Identify the correct SQL query that uses the SUM function to calculate the total sales amount in the 'sales' table.

SQL Code
SELECT SUM(sales_amount) AS total_sales
FROM sales;
Q23
Multiple Choice

Which query correctly uses the AVG function to find the average price of products in the 'products' table?

SQL Code
SELECT AVG(price) AS avg_price
FROM products;
Q24
Multiple Choice

Determine the correct SQL query that uses the MIN function to find the minimum revenue in the 'customers' table.

SQL Code
SELECT MIN(revenue) AS min_revenue
FROM customers;
Q25
Multiple Choice

Which SQL query uses the MAX function to find the highest transaction amount in the 'transactions' table?

SQL Code
SELECT MAX(transaction_amount) AS max_amount
FROM transactions;
Q26
Multiple Choice

Which query correctly uses the COUNT and AVG functions together to find the number of orders and the average order amount in the 'orders' table?

SQL Code
SELECT COUNT(order_id) AS total_orders, AVG(order_amount) AS avg_amount
FROM orders;
Q27
Multiple Choice

Determine the correct SQL query that uses the SUM and MIN functions to find the total sales and the minimum sales amount in the 'sales' table.

SQL Code
SELECT SUM(sales_amount) AS total_sales, MIN(sales_amount) AS min_sales
FROM sales;
Q28
Multiple Choice

Which SQL query uses the AVG and MAX functions together to find the average and maximum price of products in the 'products' table?

SQL Code
SELECT AVG(price) AS avg_price, MAX(price) AS max_price
FROM products;
Q29
Multiple Choice

Identify the correct query that uses the COUNT and MIN functions to find the number of clients and the minimum revenue in the 'clients' table.

SQL Code
SELECT COUNT(client_id) AS total_clients, MIN(revenue) AS min_revenue
FROM clients;
Q30
Multiple Choice

Which SQL query correctly uses the SUM, AVG, and MAX functions together to find the total, average, and maximum transaction amounts in the 'transactions' table?

SQL Code
SELECT SUM(transaction_amount) AS total_amount, AVG(transaction_amount) AS avg_amount, MAX(transaction_amount) AS max_amount
FROM transactions;