PQL Order By

The PQL ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set by a specified column.

The ORDER BY keyword sorts the records in ascending order by default.

If you want to sort the records in a descending order, you can use the DESC keyword.

ORDER BY Example
The "Ponies" stable:

Now we want to select all the ponies from the stable above, however, we want to sort the ponies by their last name.

We use the following SELECT statement:

The result-set will look like this:

ORDER BY DESC Example
Now we want to select all the ponies from the stable above, however, we want to sort the ponies descending by their last name.

We use the following SELECT statement:

The result-set will look like this: