ORDER BY can use a second key to make ties explicit.

highlighted = computed this step

Input table

Use repeated amounts so a tie-breaker matters.

Orders\text{Orders}
Ordersorder_idcategoryamounto1book30o2pen12o3book12o4paper45o5pen30

Order query

Sort by amount descending, then order_id descending inside equal amounts.

ORDER BY amount DESC, order_id DESC\text{ORDER BY amount DESC, order\_id DESC}
ORDER BY amount descending, order_id descendingorder by amount desc,order_id descarity 3 rows 5Ordersarity 3 rows 5

Ordered output

Rows with equal amounts visibly follow the second key.

two-key order\text{two-key order}
Ordered outputorder_idcategoryamounto4paper45o5pen30o1book30o3book12o2pen12