2,241 views

1 Answer

Best answer
8 votes
8 votes

Here the key thing is "anyone" in CS department actually means : 

"everyone not someone"

 So according to first query we are extracting s1.sid of which we are interested..Now actually if we find any other student s2.sid s.t. s2's rank is less than or equal to s1 meaning s1's rank is greater than equal to s2's rank then we are going to discard such s1.sid..

Hence in case the subquery result comes empty suggesting that there is no such instance and hence it is assured that the particular s1.sid has rank less than every other student represented by s2.sid..

Hence first query is true..

As far as second query is concerned it does not guarantee that s1 rank is less than all other students..If any tuple satisfies in the subquery then s1 is returned..Hence 2nd query is not according to specification..


Previous Gate QS

Good Read

selected by

Related questions

0 votes
0 votes
1 answer
3
rayhanrjt asked Jan 6, 2023
719 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
2 votes
2 votes
1 answer
4
Subhrangsu asked Jun 18, 2022
431 views
Write SQL query to show all employees hired on June 4,1984 (non-default format)emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)