Table Employee has 10 records. It has a non-NULL SALARY column which is also UNIQUE.
The SQL statement
SELECT COUNT(*) FROM Employee WHERE SALARY > ANY (SELECT SALARY FROM EMPLOYEE);
prints
A. 10
B. 9
C. 5
D. 0
Answer: Option B
Solution (By Examveda Team)
ANY compares a value with each of the values in a list or results from a query and evaluates to true if the result of an inner query contains at least one row. ANY must be preceded by comparison operators(=, >, <, <=, >=, <>).
Employee table has 10 records and each value in non-NULL SALARY column is unique i.e different. So, in that 10 records one of the record will be minimum which cannot be greater than any nine value of the salary column. Hence the condition
WHERE SALARY > ANY (SELECT SALARY FROM employee)
will be true nine times. So, the COUNT(*) outputs 9.
If i can't see your comments,I have doubt on it always.😄
sorry but what is happen if table one have 4 records but table 2 have 6 records
Suppose we have a table with 10 records
30
40
50
20
10
2
8
9
7
5
The smallest one is 2 so how we get 2 after comparing it with other 9 numbers so counting of comparison is 9 and the 10th number is 2.. So ans is 9 we have to count the number of comparison..
I think counting numbers 0 to 9
Suppose there are 10 salary
1
2
3
4
5
6
7
8
9
10
Now any will compare all salary. But 1 is always min from all of these. Thats why we will get 9 large only
am not getting it!
can u explain it in simple words!
am not getting it!
can u explain it in simple words!