Sobes.tech
Junior — Middle

What sorting and filtering methods of data with SQL are you familiar with?

sobes.tech AI

Answer from AI

The following methods are used for sorting and filtering data in SQL:

  • Sorting: the ORDER BY operator. It allows sorting data by one or more columns in ascending (ASC) or descending (DESC) order.
SELECT * FROM employees ORDER BY salary DESC;
  • Filtering: the WHERE operator. It allows selecting rows that meet certain conditions.
SELECT * FROM employees WHERE department = 'Sales';
  • Combining filtering and sorting:
SELECT * FROM employees WHERE age > 30 ORDER BY last_name ASC;

For more complex filtering, operators like LIKE, IN, BETWEEN can be used, and for sorting — multiple columns with different sorting directions.

What sorting and filtering methods of data with SQL… - sobes.tech