Loading

Quipoin Menu

Learn • Practice • Grow

sql / Derived Tables
mcq
Direction: Choose the correct option

Q1.

What is a derived table?
A. Permanent table
B. View
C. Temporary table
D. Subquery in FROM clause
Direction: Choose the correct option

Q2.

SELECT dept_id, avg_salary FROM (SELECT dept_id, AVG(salary) AS avg_salary FROM employees GROUP BY dept_id) AS dept_avg WHERE avg_salary > 50000;
What is 'dept_avg'?
A. View name
B. Database name
C. Column name
D. Table alias for derived table
Direction: Choose the correct option

Q3.

SELECT d.dept_name, stats.emp_count FROM departments d JOIN (SELECT dept_id, COUNT(*) AS emp_count FROM employees GROUP BY dept_id) AS stats ON d.id = stats.dept_id;
What is being joined?
A. View and table
B. Two tables
C. Two derived tables
D. Table and derived table
Direction: Choose the correct option

Q4.

SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC) AS rn FROM employees) AS ranked WHERE rn <= 3;
What does this find?
A. Department list
B. Top 3 earners per department
C. All employees
D. Top 3 overall
Direction: Choose the correct option

Q5.

What is a limitation of derived tables?
A. All of the above
B. Cannot be referenced multiple times
C. Slower than views
D. No indexes