Ordering with the Order By

Learn about the order by clause, kNN ordering, and GiST indexes.

The SQL order by clause is pretty well-known because SQL doesn’t guarantee any ordering of the result set of any query except when we use the order by clause.

In its simplest form, the order by works with one column or several columns that are part of our data model. In some cases, it might even allow PostgreSQL to return the data in the right order by following an existing index.

Get hands-on with 1400+ tech skills courses.