Sobes.tech
Junior — Middle

Can you explain what the ORDER BY operator in SQL is used for and how it works?

sobes.tech AI

Answer from AI

The ORDER BY operator in SQL is used to sort the query results by one or more columns. By default, sorting is in ascending order (ASC), but you can also specify descending order (DESC).

Example:

SELECT name, age FROM users ORDER BY age DESC;

This query will return a list of users sorted by age from oldest to youngest. ORDER BY helps organize data for easier display or further processing.

Can you explain what the ORDER BY operator in SQL is… - sobes.tech