recategorized
1,647 views
2 votes
2 votes

Consider the following relation:

Works(emp_name, company_name,salary)

Here,emp name is primary key.

Consider the following SQL query

Select emp name
From works T
where salary > (select avg(salary)
               from works S
               where  T. company name =
                      S. company name)

The above query is for following:

  1. Find the highest paid employee who earns more  than the average salary of all employees of his company.
  2. Find the highest paid employee who earns more  than the average salary of all  the employees of all the companies.
  3. Find all employees who earn more than the average salary of all employees all the companies.
  4. Find all employees who earn more than the average salary of all employees of their company.
recategorized

6 Answers

0 votes
0 votes

Inner loop finds the average of the salary of employees of their respective companies. Outer loop compares each employee with the average salary of employees of their companies. Hence option “C” is correct 

Answer:

Related questions

1 votes
1 votes
3 answers
4
go_editor asked Jan 31, 2017
8,545 views
If following sequence of keys are inserted in a B+ tree with K(=3) pointers:8, 5, 1, 7, 3, 12, 9, 6Which of the following shall be correct B+ tree?