Skip to main content
ORDER BY sorts the results. Name a column and a direction: DESC for largest first, or ASC for smallest first.
You can sort by more than one column. Later keys break ties in the earlier ones.
Sorting is what makes LIMIT meaningful, since it decides which rows the cap keeps. It also sets the order that WITH CUMULATIVE_VALUES accumulates over.