MySQL Database Quiz Questions

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

In MySQL, you can use the AS keyword to create an alias for a column in a SELECT statement.

Q2
True / False

MySQL does not allow using spaces in column aliases.

Q3
True / False

When using an alias in MySQL, the alias can only be referenced in the SELECT clause.

Q4
True / False

In MySQL, aliases can be used to rename columns for display purposes without affecting the actual column names in the database.

Q5
True / False

In MySQL, you must always use the AS keyword to define an alias for a column.

Q6
True / False

In MySQL, using an alias for a column allows you to use that alias in the WHERE clause of the same query.

Q7
True / False

In MySQL, you can use a column alias in the GROUP BY clause of the same query.

Q8
True / False

In MySQL, you can reference a column alias in the HAVING clause of the same query.

Q9
True / False

In MySQL, column aliases can be used in the ORDER BY clause of the same query.

Q10
True / False

In MySQL certification exams, you might be asked to use aliases to improve the readability of the result set in complex queries.

Q11
Single Choice

Which of the following is the correct way to use an alias for a column in MySQL?

SQL Code
SELECT first_name AS name FROM employees;
Q12
Single Choice

What is the purpose of using an alias in a SQL query?

Q13
Single Choice

What will be the column names in the result set?

Q14
Single Choice

Which MySQL SQL statement will correctly use an alias for the table employees to join with itself?

SQL Code
SELECT e1.first_name, e2.manager_id
FROM employees AS e1
JOIN employees AS e2 ON e1.employee_id = e2.manager_id;
Q15
Single Choice

Given the query below, what will be the result of the alias used?

SQL Code
SELECT department_id, COUNT(*) AS total_employees
FROM employees
GROUP BY department_id;
Q16
Single Choice

What is the effect of the following SQL query?

SQL Code
SELECT e.first_name, e.last_name, d.name AS department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id;
Q17
Single Choice

Given the following SQL statement, what will be the outcome of the alias full_name?

SQL Code
SELECT CONCAT(first_name, ' ', last_name) AS full_name, salary
FROM employees
ORDER BY full_name;
Q18
Single Choice

Consider the SQL query below. What does the alias total_sales represent?

SQL Code
SELECT p.product_name, SUM(o.quantity * o.unit_price) AS total_sales
FROM products p
JOIN order_details o ON p.product_id = o.product_id
GROUP BY p.product_name
HAVING total_sales > 1000;
Q19
Single Choice

What will the alias highest_salary represent in the following SQL query?

SQL Code
SELECT department_id, MAX(salary) AS highest_salary
FROM employees
GROUP BY department_id;
Q20
Single Choice

In a complex SQL query involving multiple joins, how can aliases improve readability and performance?

Q21
Multiple Choice

Which query uses an alias to rename the 'employees' table to 'e' in a SELECT statement?

SQL Code
SELECT e.name, e.salary
FROM employees e
WHERE e.department_id = 3;
Q22
Multiple Choice

Identify the correct SQL query that uses an alias to rename the 'order_amount' column as 'Total' in the result set.

SQL Code
SELECT order_id, order_amount AS Total
FROM orders
WHERE order_date = '2024-01-01';
Q23
Multiple Choice

Which query correctly renames the 'products' table to 'p' and the 'product_name' column to 'Name'?

SQL Code
SELECT p.product_id, p.product_name AS Name
FROM products p
WHERE p.price > 100;
Q24
Multiple Choice

Determine the correct SQL query that uses an alias to rename the 'customers' table as 'c' and the 'email' column as 'EmailAddress'.

SQL Code
SELECT c.customer_id, c.email AS EmailAddress
FROM customers c
WHERE c.country = 'USA';
Q25
Multiple Choice

Which SQL query uses an alias to rename both the 'inventory' table to 'inv' and the 'item_code' column to 'Code'?

SQL Code
SELECT inv.item_code AS Code, inv.quantity
FROM inventory inv
WHERE inv.quantity > 50;
Q26
Multiple Choice

Which query correctly uses an alias to rename the 'sales' table as 's' and the 'sales_amount' column as 'TotalSales'?

SQL Code
SELECT s.sales_rep, s.sales_amount AS TotalSales
FROM sales s
WHERE s.sales_rep = 'John Doe';
Q27
Multiple Choice

Determine the correct SQL query that uses an alias to rename the 'transactions' table as 't' and the 'transaction_date' column as 'Date'.

SQL Code
SELECT t.transaction_id, t.transaction_date AS Date
FROM transactions t
WHERE t.transaction_amount > 1000;
Q28
Multiple Choice

Which SQL query uses an alias to rename the 'projects' table as 'p' and the 'project_name' column as 'Project'?

SQL Code
SELECT p.project_id, p.project_name AS Project
FROM projects p
WHERE p.budget > 50000;
Q29
Multiple Choice

Identify the correct query that uses an alias to rename the 'clients' table as 'cl' and the 'client_name' column as 'Name'.

SQL Code
SELECT cl.client_id, cl.client_name AS Name
FROM clients cl
WHERE cl.revenue > 100000;
Q30
Multiple Choice

Which SQL query correctly uses an alias to rename the 'students' table as 's' and the 'grade' column as 'GradeLevel'?

SQL Code
SELECT s.student_id, s.grade AS GradeLevel
FROM students s
WHERE s.grade > 80;