ORDER BY category ASC, amount DESC places text categories alphabetically and sorts amounts high-to-low inside each category.

highlighted = computed this step

Input table

Start with the same order rows, mixed across categories and amounts.

Orders\text{Orders}
Ordersorder_idcategoryamounto1book30o2pen12o3book12o4paper45o5pen30

Order query

Sort text categories alphabetically first, then sort amount high-to-low within each category.

ORDER BY category ASC, amount DESC\text{ORDER BY category ASC, amount DESC}
ORDER BY category ascending, amount descendingorder by category asc,amount descarity 3 rows 5Ordersarity 3 rows 5

Ordered output

Rows appear by category, with larger amounts before smaller amounts inside the same category.

category then amount order\text{category then amount order}
Ordered outputorder_idcategoryamounto1book30o3book12o4paper45o5pen30o2pen12