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;
- A. 5, 6
- B. 6, 6
- C. 6, 7
- 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
- Schedule: W1(A), R2(A), C2, C1, where C means commit. Which classification is correct?
- Under basic timestamp ordering, TS(T1) = 10 and TS(T2) = 20. T2 has read item X, so read-TS(X) = 20. T1 now issues write(X). What happens?
- R(A, B, C, D, E, F) has FDs A → B, BC → D, D → E, E → C, CE → F. Which of these is NOT a candidate key?
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Which isolation-related statement is correct for the SQL standard levels?
- Which statement about dense and sparse indexes is correct?