ExamVeda
Login
Home
This question belongs to SQL Sql Miscellaneous
Sql Miscellaneous
?

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

Answer & Solution
Correct Answer: Option B

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.

Examveda
Question posted by Examveda
Community

Join the Discussion

7 Comments
Nishar_Kn
Nishar_Kn 4 years ago
If i can't see your comments,I have doubt on it always.😄
Rose Jamal
Rose Jamal 5 years ago
sorry but what is happen if table one have 4 records but table 2 have 6 records
Swati Kumari
Swati Kumari 6 years ago
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..
Sangareswari Ramadoss
Sangareswari Ramadoss 8 years ago
I think counting numbers 0 to 9
Piyush Jain
Piyush Jain 9 years ago
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
Mine Picks
Mine Picks 9 years ago
am not getting it!
can u explain it in simple words!
Mine Picks
Mine Picks 9 years ago
am not getting it!
can u explain it in simple words!