You are given the following SQL statement. SELECT e.employee_id, e.salary FROM employees e WHERE e.salary > ( SELECT AVG(s.salary) FROM employees s WHERE s.department_id = e.department_id ); Which of the following queries correctly rewrites this logic using an uncorrelated approach, such as a join or uncorrelated subquery or subquery factoring?Single choice
SELECT e.employee_id, e.salary FROM employees e JOIN employees s ON e.department_id = s.department_id WHERE e.salary > AVG(s.salary);
WITH dept_avg AS ( SELECT department_id, AVG(salary) AS avg_salary FROM employees GROUP BY department_id ) SELECT e.employee_id, e.salary FROM employees e JOIN dept_avg d ON e.department_id = d.department_id WHERE e.salary > d.avg_salary;
SELECT employee_id, salary FROM employees WHERE department_id IN ( SELECT department_id FROM employees GROUP BY department_id HAVING AVG(salary) < salary );
SELECT employee_id, salary FROM employees WHERE salary > ( SELECT MAX(salary) FROM employees WHERE department_id = employees.department_id );
Log in for full answers
We've collected over 50,000 authentic original questions and detailed explanations from around the globe. Log in now and get instant access to the answers!
Similar Questions
A type of query that is placed within a WHERE or HAVING clause of another query is called a:
You are tasked with identifying all ORDER# from the ORDERITEMS table where the total (quantity * paideach) for that order is greater than the total amount due for every order placed by customers in the 'FL' state. Which of the following queries correctly uses a multiple-row subquery to achieve this?
Based on the contents of the BOOKS table, which line of the following SQL statement contains an error? 1 SELECT isbn, title, pubid, cost, retail 2 FROM books 3 WHERE (pubid, cost) = 4 (SELECT pubid, MIN(cost) 5 FROM books 6 GROUP BY pubid); BOOKS table:
Question at position 55 Subqueries can only be used in the WHERE clause.TrueFalse
More Practical Tools for Students Powered by AI Study Helper
Making Your Study Simpler
Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!