'order by' query


I was learning about the ORDER BY function as part of queries. I didn’t understand the following statement. Can someone please help me understand what this means?

The column that we ORDER BY doesn’t even have to be one of the columns that we’re displaying.

Thanks in advance!

ORDER BY clause doesn’t always need to refer to a column in the SELECT statement.


SELECT id, departments
FROM employees
ORDER BY salary;

Oh, thank you! I now understand this!

1 Like