316 views
1 votes
1 votes

Which of the following query will give name of the employee who is earning maximum salary?

  • 1. 

    Select name from emp where sal=(Select max(sal) from emp);

    img

  • 2. 

    Select name from emp where sal>=all(Select max(sal) from emp);

    img

  • 3. 

    Both a and b are correct queries

    img

  • 4. 

    Both a and b are incorrect queries

1 Answer

Best answer
4 votes
4 votes

Both are correct queries..

As far as the first query is concerned , first max(sal) will be computed and accordingly the corresponding employee names..

Second query also does the same thing..As there is one tuple resulting from inner query as we are finding max salary, so ALL will give same result provided we use >= or = signs..

In fact , this query will also work :

Select name from emp where sal >= all(Select sal from emp);

img

Hence  3) is the correct answer..

selected by

Related questions

1 votes
1 votes
1 answer
2
Na462 asked Jan 19, 2019
1,259 views
1 votes
1 votes
1 answer
3
Shubhanshu asked Dec 24, 2018
1,342 views
According to me it should be – “Retrieve the names of all students with a lower rank, than all students with age < 18 ”
0 votes
0 votes
0 answers
4
Shivani gaikawad asked Nov 3, 2018
567 views