in Databases edited by
615 views
1 vote
1 vote

Table employees 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);

  1. $10$
  2. $9$
  3. $5$
  4. $0$
in Databases edited by
615 views

1 Answer

2 votes
2 votes

Here ans should be 0

 number salary
1 100
2 200
3 300
4 400
5 500
6 600
7 700
8 800
9 900
10 1000

first inner query will execute and result will be {100,200,300,400,500,600,700,800,900.1000}

then outer query execute but in count number of employee whose salary greater  than {100,200,300,400,500,600,700,800,900.1000}. this condition will be false because  no salary greater than all these salary so ans will be 0.

 where x> {100,200,300,400,500,600,700,800,900.1000} this is false

find number of employee whose salary greater than all  given salary.( english version of above query)

ans 0

 

 

2 Comments

what will be the output if ALL is replaced by ANY?
0
0
In that, it is particular to table,how the data is distributed, but in general, we can say all tuples where A is not the least value will be printed
0
0
Answer:

Related questions