'order by' query

Hello!

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.

Ex:

SELECT id, departments
FROM employees
ORDER BY salary;
2 Likes

Oh, thank you! I now understand this!

1 Like