The Employee table has exactly 10 rows. Its SALARY column is non-NULL and…

2025

The Employee table has exactly 10 rows. Its SALARY column is non-NULL and UNIQUE. No individual salary values are needed.

What does the following SQL statement return?

SELECT COUNT(*)
FROM Employee
WHERE SALARY > ANY (SELECT SALARY FROM Employee);

Answer: B. 9CONCEPT For a non-empty subquery, x > ANY(S) is true when x is greater than at least one member of S. When S contains all values from the same column, this is…

  1. A.

    10

  2. B.

    9

  3. C.

    5

  4. D.

    0

Attempted by 469 students.

Show answer & explanation

Correct answer: B

CONCEPT For a non-empty subquery, x > ANY(S) is true when x is greater than at least one member of S. When S contains all values from the same column, this is equivalent to testing x > MIN(S).

COUNT(*) counts only the rows for which the WHERE predicate evaluates to TRUE.

APPLICATION Apply the rule to the 10 distinct, non-NULL salary values.

  1. The subquery returns all 10 SALARY values.

  2. For each outer row, SALARY > ANY(all salaries) is equivalent to SALARY > MIN(all salaries).

  3. Because SALARY is UNIQUE, exactly one row contains the minimum salary.

  4. That minimum row has no smaller salary in the returned set, so its predicate is FALSE. Each of the other nine rows has the minimum as a smaller returned value, so its predicate is TRUE.

  5. COUNT(*) therefore counts 10 − 1 = 9 rows.

CROSS-CHECK Order the salaries as s₁ < s₂ < … < s₁₀. The predicate is false only for s₁ and true for s₂ through s₁₀, again giving 9 rows.

Result: 9.

Explore the full course: Lti Mindtree Preparation

Loading lesson…