CS FundamentalsModerateProduct-company placement
Player(pid, team, runs) has rows (1, 'A', 50), (2, 'A', 70), (3, 'A', 70), (4, 'B', 40), (5, 'B', NULL), (6, 'B', 90), (7, 'C', NULL). For player 1, what are RANK() OVER (ORDER BY runs DESC NULLS LAST) and DENSE_RANK() OVER (ORDER BY runs DESC NULLS LAST)?
- A. 3 and 3
- B. 4 and 4
- C. 4 and 3
- D. 3 and 2
Correct answer: C. 4 and 3
Ordered: 90, 70, 70, 50, 40, NULL, NULL. RANK leaves a gap after the tie (1, 2, 2, 4) so 50 gets 4; DENSE_RANK has no gaps (1, 2, 2, 3) so 50 gets 3. 3 and 2 counts the higher rows but forgets to add 1.
More DBMS and SQL questions
- Pay(d, amt) has rows (1, 10), (2, 20), (2, 30), (3, 40). For the row (2, 20), what value does SUM(amt) OVER (ORDER BY d) give?
- What does this query return? SELECT CASE NULL WHEN NULL THEN 'eq' ELSE 'ne' END, CASE WHEN NULL IS NULL THEN 'eq' ELSE 'ne' END;
- Skill(emp, sk) has rows (r, sql), (r, py), (r, go), (s, sql), (s, py), (t, sql), (t, go), (t, py), (t, c). Req(sk) has rows (sql), (py)…
- Emp(eid, name, mgr, sal) has rows (1, Kiran, NULL, 100), (2, Lata, 1, 80), (3, Mohan, 1, 120), (4, Neha, 2, 90), (5, Om, 4, 60), (6, Pari…
- Using Emp(eid, name, mgr, sal) with rows (1, Kiran, NULL, 100), (2, Lata, 1, 80), (3, Mohan, 1, 120), (4, Neha, 2, 90), (5, Om, 4, 60)…
- Fee(sid, fee) has rows (1, 500), (2, 700), (3, 700), (4, 400), (5, 900), (6, 400). What does this return? SELECT SUM(fee) FROM Fee f WHERE…