Practice Test Answer Key
Total Score: 8 / 15
Correct Answers: 8 / 15
1. Given the table Sales, what will the following query return?
SELECT Region, SUM(Sales)
FROM Sales
WHERE Sales > 1000
GROUP BY Region
WITH ROLLUP;
1. Summarized sales data with regional subtotals and grand total. (Your Selection)
2. Error because WITH ROLLUP cannot be used with WHERE. (Your Selection)
3. Only regions where sales are greater than 1000.
4. Same result as without WITH ROLLUP.
Correct Answer: Option 1
Your Answer: Option 2
2. What is the purpose of the EXISTS keyword ?
1. Checks if a subquery returns rows. (Your Selection)
2. Returns the first row of a subquery.
3. Returns TRUE if a condition is met.
4. Joins two tables.
Correct Answer: Option 1
Your Answer: Option 1
3. What is the difference between UNION and UNION ALL?
1. UNION removes duplicates, while UNION ALL keeps them. (Your Selection)
2. UNION ALL removes duplicates, while UNION keeps them.
3. Both remove duplicates.
4. Both keep duplicates.
Correct Answer: Option 1
Your Answer: Option 1
4. What does the following SQL query return?
SELECT EmployeeID, ManagerID
FROM Employees
CONNECT BY PRIOR EmployeeID = ManagerID;
1. Returns employees reporting directly to their managers. (Your Selection)
2. Returns a hierarchical tree structure of employees.
3. Returns only managers.
4. Results in an error.
Correct Answer: Option 2
Your Answer: Option 1
5. What does this query do?
SELECT Department, COUNT(*)
FROM Employees
GROUP BY Department
HAVING COUNT(*) > 10;
1. Returns departments with at least 10 employees. (Your Selection)
2. Returns all departments.
3. Returns an error.
4. Returns only employees with more than 10 years of experience.
Correct Answer: Option 1
Your Answer: Option 1
6. Which SQL command is used to remove duplicate records from the result set?
1. DISTINCT (Your Selection)
2. DELETE
3. REMOVE
4. UNIQUE
Correct Answer: Option 1
Your Answer: Option 1
7. What will this SQL query return?
SELECT Name, COALESCE(Phone, Email, 'No Contact')
FROM Customers;
1. First non-null value from Phone, Email, or 'No Contact'.
2. Only Phone values.
3. Only Email values.
4. Returns NULL if both Phone and Email are NULL. (Your Selection)
Correct Answer: Option 1
Your Answer: Option 4
8. What will happen if you run the following query?
DELETE FROM Orders
WHERE OrderID IN (SELECT OrderID FROM Orders WHERE CustomerID = 5);
1. Deletes all orders for CustomerID 5. (Your Selection)
2. Deletes one order for CustomerID 5.
3. Returns an error.
4. Does nothing.
Correct Answer: Option 1
Your Answer: Option 1
9. What does the following SQL query do?
SELECT *
FROM Employees
WHERE Salary > (SELECT AVG(Salary) FROM Employees);
1. Returns all employees.
2. Returns employees with above-average salaries. (Your Selection)
3. Returns employees with below-average salaries.
4. Returns an error.
Correct Answer: Option 2
Your Answer: Option 2
10. What is the purpose of the DENSE_RANK() function in SQL?
1. Assigns a unique rank without skipping numbers for duplicates. (Your Selection)
2. Assigns the same rank for duplicate values but skips the next rank.
(Your Selection)
3. Removes duplicates from the result set.
4. Returns the total number of rows in a table.
Correct Answer: Option 1
Your Answer: Option 2
11. What is the result of the following SQL statement?
SELECT NULL = NULL;
1. TRUE (Your Selection)
2. FALSE
3. NULL (Your Selection)
4. Error
Correct Answer: Option 3
Your Answer: Option 3
12. What happens if you execute this SQL statement?
SELECT EmployeeID, Department, SUM(Salary)
FROM Employees;
1. Returns the total salary for each department.
2. Returns an error due to the missing GROUP BY. (Your Selection)
3. Returns the total salary of all employees
4. Returns one row per department with summed salaries.
Correct Answer: Option 2
Your Answer: Option 2
13. What will the following query do?
SELECT Name, COUNT(*) OVER (PARTITION BY Department)
FROM Employees;
1. Counts all employees.
2. Counts employees within each department.
3. Returns an error. (Your Selection)
4. Returns the first employee's name and count per department.
Correct Answer: Option 2
Your Answer: Option 3
14. What is the result of the following query?
SELECT Department, COUNT(EmployeeID)
FROM Employees
GROUP BY Department
ORDER BY 2 DESC;
1. Orders by department name.
2. Orders by count of employees in ascending order.
3. Orders by count of employees in descending order. (Your Selection)
4. Orders randomly.
Correct Answer: Option 3
Your Answer: Option 3
15. What will be the output of the following SQL query?
SELECT COUNT(*)
FROM Orders
WHERE OrderDate BETWEEN '2024-01-01' AND '2024-12-31'
HAVING COUNT(*) > 100;
1. Returns the count of orders between the given dates.
2. Returns an error.
3. Returns the count only if it's greater than 100. (Your Selection)
4. Returns NULL if no orders exist.
Correct Answer: Option 2
Your Answer: Option 3