CS FundamentalsHardGATE CS
M(s) holds the scores 90, 85, 85, 80, 80, 80, 70, 70, 60. What is the sum over all nine rows of (RANK() OVER (ORDER BY s DESC) - DENSE_RANK() OVER (ORDER BY s DESC))?
- A. 10
- B. 13
- C. 16
- D. 40
Correct answer: B. 13
RANK leaves gaps after ties while DENSE_RANK does not: ranks are 1, 2, 2, 4, 4, 4, 7, 7, 9 and dense ranks 1, 2, 2, 3, 3, 3, 4, 4, 5, so the differences sum to 13.
More DBMS and SQL questions
- A(x) = (3, 5, NULL, 8, 9, 12) and B(x) = (4, NULL, 6). How many rows does SELECT x FROM A WHERE x > ALL (SELECT x FROM B) return? (ALL is…
- R(A, B) has 5000 tuples with V(R, B) = 100 distinct B values. S(B, C) has 3000 tuples with V(S, B) = 300 and V(S, C) = 60. Using the…
- R(A, B, C, D, E, F, G) has the functional dependencies AB -> C, C -> D, D -> E, E -> C, F -> G, BG -> A and AE -> F. How many candidate…
- R(A, B, C, D, E) has the functional dependencies A -> B, BC -> D, D -> E and E -> B. The decomposition R1(A, B), R2(B, C, D), R3(A, D, E) is
- Transactions are T1: R(A) W(A) R(B); T2: W(A) R(B) W(B); T3: R(B) W(A) (each executes its operations in the order shown). Of all possible…
- Basic timestamp ordering assigns timestamps TS(T1) < TS(T2) < TS(T3) < TS(T4) = 1, 2, 3, 4. For a data item Q, R(Q) is rejected if TS(T) <…