CS FundamentalsVery hardProduct-company placement
Ord(oid, cid, amt) has no row with cid = 99. What do these return? Q1: SELECT SUM(amt), COUNT(*) FROM Ord WHERE cid = 99; Q2: SELECT cid, COUNT(*) FROM Ord WHERE cid = 99 GROUP BY cid;
- A. Q1: one row (NULL, 0); Q2: no rows
- B. Q1: one row (0, 0); Q2: one row (99, 0)
- C. Q1: no rows; Q2: no rows
- D. Q1: one row (NULL, 0); Q2: one row (99, 0)
Correct answer: A. Q1: one row (NULL, 0); Q2: no rows
An aggregate without GROUP BY always yields exactly one row: SUM of nothing is NULL and COUNT(*) is 0. With GROUP BY, there are no groups at all, so Q2 returns no rows.
More DBMS and SQL questions
- R(A, B, C, D, E, F) has functional dependencies AB → C, C → D, D → E, E → A and F → B. How many superkeys does R have?
- R(A, B, C, D, E, F) has functional dependencies A → BC, CD → E, E → A and B → F. It is decomposed into R1(A, B, C, F) and R2(A, C, D, E)…
- R(A, B, C, D, E) has functional dependencies A → C, B → D and CD → E. It is decomposed into R1(A, C), R2(B, D) and R3(A, B, E). Is the…
- R(A, B, C, D, E) has functional dependencies AB → CDE, C → A and D → E. What is the highest normal form R satisfies?
- R(A, B, C, D, E) has functional dependencies BC → A, A → B, D → E and E → D. How many candidate keys does R have, and what is its highest…
- A clinic stores Booking(patient, specialty, doctor). Each doctor has exactly one specialty, and each patient sees exactly one doctor per…