Evaluate the SQL statement: SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a,   (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) b   WHERE a.dept_id = b.dept_id AND a.sal < b.maxsal;   Which of the following statement is correct?

Category: SQLEvaluate the SQL statement: SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a,   (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) b   WHERE a.dept_id = b.dept_id AND a.sal < b.maxsal;   Which of the following statement is correct?
Editor">Editor Staff asked 2 years ago

Evaluate the SQL statement:

 

  1. SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a,  
  2. (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) b  
  3. WHERE a.dept_id = b.dept_id AND a.sal < b.maxsal;  

Which of the following statement is correct?

  1. The statement gives an error at line 1.
  2. The statement gives an error at line 6.
  3. The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all departments that pay less salary than the maximum salary paid in the company.
  4. The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all employees who earn less than the maximum salary in their department.
1 Answers
Editor">Editor Staff answered 2 years ago

Answer:
4.The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all employees who earn less than the maximum salary in their department.
Explanation: Option D is the correct choice because it is the example of an inline view, which is the subquery in the FROM clause of the main query.