Practice free →
HomeGATE CSEcomputerscienceDatabase Management Systems › In `ORDER BY age ASC, name DESC`, how are rows o…

In `ORDER BY age ASC, name DESC`, how are rows ordered when two students share the same age?

Aby insertion order, oldest insert first
Bthe database picks arbitrarily
Cby name in DESC order (Z to A)
Dby primary key ascending
Answer & Solution
Correct answer: C. by name in DESC order (Z to A)
Multiple sort keys form a hierarchy: the first key dominates, later keys break ties. With two students of the same age, name DESC decides; the student whose name sorts later alphabetically (Z-side) appears first. ORDER BY makes the ordering deterministic instead of leaving it to the engine.
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions