Vidyalelo
SQL · Q46

SQL

Programming · SQL · question 46

Q46

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 > ALL (SELECT SALARY FROM EMPLOYEE); prints

A.
10
B.
9
C.
5
D.
0
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
In this statement, you are comparing the SALARY column of each employee with the result of the subquery that selects all SALARY values from the same table. Since the SALARY column is unique, there is no salary greater than ALL the salaries in the same table, including itself. Therefore, the condition SALARY > ALL (SELECT SALARY FROM EMPLOYEE) will always be false for all records, resulting in a count of 0.