CS FundamentalsHardProduct-company MCQ 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 CASE WHEN salary > 60000 THEN 'H'
WHEN salary <= 60000 THEN 'L'
ELSE 'U' END AS band,
COUNT(*)
FROM Emp GROUP BY band;- A. H 3, L 3
- B. H 4, L 3
- C. H 3, L 3, U 1
- D. H 3, L 4
Correct answer: C. H 3, L 3, U 1
H: Ravi, Meena, Kiran. L: Asha, John, Dev. Lata's NULL salary fails both comparisons (UNKNOWN), so it falls to ELSE 'U'. The two WHEN conditions look exhaustive but are not when NULLs exist.
More DBMS and SQL questions
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Enroll(sid, cid) rows: (1, 'C1'), (1, 'C2'), (2, 'C1'), (3, 'C1'), (3, 'C2'), (3, 'C3'), (4, 'C3'). Table Course(cid) rows: ('C1')…
- R(A, B, C, D, E) has FDs A → B, B → C, C → A, D → E. How many candidate keys does R have, and what is its highest normal form?