edited by
859 views

1 Answer

Best answer
3 3 votes
There seems to be some printing error in the question. If there is no typo then answer is D because both of these queries have syntax error. Instance "s" of "employee" table is not declared, hence "s.department" and "s.salary" will throw errors.

If we consider these typos to be unintentional, and go to the spirit of the query then Q1 will give correct result and Q2 is incorrect. So in this case answer will be A.

Q2 will give incorrect result because if any employee has salary greater than salary of (any employee whose dept is 5), it'll be shown in the output. Even those employees whose dept is 5 will be shown, which should not be the case.

Consider the table as below: employee( empid, name, dept, salary)

(1, 'a', 5, 10);
(2, 'b', 5, 20);
(3, 'c', 5, 30);

(4, 'd', 1, 10);
(5, 'e', 2, 10);

 (6, 'f', 3, 50);
 (7, 'g', 4, 60);
 (8, 'h', 6, 70);

Q1 shows empid: 6,7,8

Q2 shows empid: 2,3,6,7,8 (because empid 2 and 3 have salaries greater than empid 1 so they're also on the list.)

If in Q2, instead of "Any" we had used "All", then both queries would give same results.
selected by
Position:
Show:

Related questions

1 1 vote
1 1 answer
1.7k
1.7k views
Naveen K Verma asked Jan 10, 2018
1,715 views
Consider the following instance R.A1234BNull122The number of tuples returned by the following SQL query is _____________. select * from R as R1 where not exists (select...
1 1 vote
2 2 answers
976
976 views
Purple asked Jan 9, 2017
976 views
Consider the following instances $R.$A1234BNull122The number of tuples returned by the following $\text{SQL query}$ is$?$$>$select $*$ from $R$ as $R_{1}$ where not exist...
0 0 votes
1 1 answer
624
624 views
Purple asked Jan 30, 2016
624 views
The inner query in Q1 will select the employee having max salary from all other employees in all departments(this will return the max salaried employee in the entire comp...
1 1 vote
1 1 answer
1.2k
1.2k views
Priyansh Singh asked Mar 29, 2019
1,152 views
Given the following schema:employees(emp-id, first-name, last-name, hire-date, dept-id, salary)departments(dept-id, dept-name, manager-id, location-id)You want to display...