CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

Table Bill(id, cust, region, amt) rows: (1, 'Kavi', 'E', 300), (2, 'Lata', 'W', NULL), (3, 'Kavi', 'E', 450), (4, 'Mona', 'W', 300), (5, 'Nair', NULL, 200), (6, 'Lata', 'W', 450), (7, 'Mona', 'E', NULL). How many rows go into each tile? SELECT id, NTILE(3) OVER (ORDER BY id) FROM Bill;

  1. A. 2, 2 and 3
  2. B. 3, 2 and 2
  3. C. 3, 3 and 1
  4. D. 2, 3 and 2

Correct answer: B. 3, 2 and 2

NTILE splits 7 rows into 3 groups whose sizes differ by at most one, giving the extra rows to the earlier tiles: 3, 2, 2 (ids 1-3, 4-5, 6-7).

More DBMS and SQL questions

Exams that ask this topic