Order a short result
Use a stable order before limiting rows.
What you are trying to do
A support screen shows the three highest-priority synthetic tickets.
Work through it
- Read both ORDER BY keys.
- Check how the ticket ID breaks priority ties.
- Change the row values and predict which three rows remain.
Check your work
The same input produces the same three rows in the same order.
Practice SQL
Open in SQL FlowSELECT TOP (3) TicketId, Priority FROM (VALUES (104, 1), (102, 1), (107, 2), (101, 1), (103, 3)) AS Ticket(TicketId, Priority) ORDER BY Priority, TicketId;
Commands in this lesson
Next lesson Join related rows