OCR GCSE Computer Science Complete Practice Exam 2025

Question: 1 / 400

Which command sorts records in ascending or descending order in SQL?

WHERE

UPDATE

ORDER BY

The command that sorts records in ascending or descending order in SQL is "ORDER BY". This command is used in SQL queries to specify the specific column or columns that should be used for sorting the result set. By default, the sorting is done in ascending order, but you can explicitly specify descending order by using the keyword "DESC" following the column name.

For example, if you want to sort a list of customers based on their last names in ascending order, you would use a command like:

```sql

SELECT * FROM customers

ORDER BY last_name ASC;

```

If you wanted to sort it in descending order, you would write:

```sql

SELECT * FROM customers

ORDER BY last_name DESC;

```

This specific functionality of "ORDER BY" is essential in data retrieval, as it allows users to easily analyze data in a structured manner based on their specific needs.

The other commands serve different purposes; "WHERE" is used to filter records based on specific conditions, "UPDATE" modifies existing records in a table, and "LIKE" is used in the context of pattern matching for string comparison. These commands do not have inherent sorting functionality.

Get further explanation with Examzify DeepDiveBeta

LIKE

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy