CS FundamentalsModerateTCS NQT · Infosys pattern

Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2), (4, 'John', 'Sales', 40000, 1), (5, 'Kiran', 'IT', 90000, 2), (6, 'Dev', NULL, 45000, 4), (7, 'Lata', 'Sales', NULL, 4). What does this query return?

Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2), (4, 'John', 'Sales', 40000, 1), (5, 'Kiran', 'IT', 90000, 2), (6, 'Dev', NULL, 45000, 4), (7, 'Lata', 'Sales', NULL, 4). What does this query return?
SELECT COUNT(DISTINCT salary), COUNT(salary) FROM Emp;
  1. A. 5, 6
  2. B. 6, 6
  3. C. 6, 7
  4. D. 5, 7

Correct answer: A. 5, 6

Non-NULL salaries: 50000, 70000, 70000, 40000, 90000, 45000 → COUNT = 6, distinct = 5 (70000 twice). Lata's NULL is skipped by both.

More DBMS and SQL questions

Exams that ask this topic