CS FundamentalsVery hardAmazon/Flipkart SQL round · GATE CS
Table Score(name, pts) rows: ('a', 90), ('b', 85), ('c', 90), ('d', 70), ('e', 85), ('f', 60). What does this query return?
Table Score(name, pts) rows: ('a', 90), ('b', 85), ('c', 90), ('d', 70), ('e', 85), ('f', 60).
What does this query return?
SELECT RANK() OVER (ORDER BY pts DESC),
DENSE_RANK() OVER (ORDER BY pts DESC)
FROM Score
WHERE name = 'f';- A. 1, 1
- B. 6, 5
- C. 5, 3
- D. 6, 4
Correct answer: A. 1, 1
The window is computed after WHERE, so only f's row is left and both functions give 1. Without the WHERE, f would be RANK 6, DENSE_RANK 4.
More DBMS and SQL questions
- How many of these statements are correct? 1. A table can have at most one clustering index. 2. A primary index on an ordering key field is…
- R(A, B, C, D) has functional dependencies B → C, A → BD, AC → D, C → AB. What is the highest normal form R satisfies?
- R(A, B, C, D, E, F) has functional dependencies CD → F, EF → D, F → D, AB → E. Which of the following is the complete set of candidate…
- Table P(x) rows: (1), (2), (2), (3), (NULL). Table Q(x) rows: (2), (3), (3), (NULL), (4). What does this query return? sql SELECT COUNT()…
- On R(A, B, C, D, E), F = {AE → D, A → CD, B → A} and G = {B → ACD, A → CD}. Which statement is correct? ("F covers G" means every FD of G…
- R(A, B, C, D, E, F) has functional dependencies BF → A, D → E, AC → F, BD → A, A → B. Which of these attribute sets is NOT a superkey of R?