CS FundamentalsModerateCapgemini · Cognizant GenC
Dept(d) has rows 1, 2, 3 and Emp(e, d) has rows (a, 1), (b, 1), (c, 2). How many rows does SELECT D.d FROM Dept D LEFT JOIN Emp E ON D.d = E.d return?
- A. 3
- B. 5
- C. 4
- D. 6
Correct answer: C. 4
Dept 1 matches twice, dept 2 once and dept 3 has no match but is kept with NULLs: 2 + 1 + 1 = 4 rows.
More DBMS and SQL questions
- R(A, B, C, D) has the functional dependencies AB -> C, C -> D and D -> A. How many candidate keys does R have?
- S(v) has rows 1, 2, 3 and U(v) has rows 2, NULL. What does SELECT COUNT() FROM S WHERE v NOT IN (SELECT v FROM U) return?
- A(x) holds 1, 2, 2, 3 and B(x) holds 2, 3, 3, 4. How many rows does SELECT x FROM A UNION SELECT x FROM B return?
- R(A, B, C) has the functional dependencies AB -> C and C -> B. Which is the highest normal form that R satisfies?
- T(v) holds 40, 10, 30, 20, 50. What does SELECT v FROM T ORDER BY v DESC LIMIT 2 OFFSET 1 return, in order?
- T(x) holds 10, NULL, 20, 30, NULL. What does SELECT AVG(x) FROM T return?