A Level Computer Science OCR Test 2025 – 400 Free Practice Questions to Pass the Exam

Question: 1 / 400

What keyword in SQL is used to specify the fields that should be sorted in a record?

GROUP BY

ORDER BY

The keyword used in SQL to specify the fields that should be sorted in a record is "ORDER BY." This clause allows you to define the order in which the results of a query are to be presented. By using "ORDER BY," you can sort the data either in ascending order (the default) or descending order by including the "ASC" or "DESC" keywords, respectively.

For example, if you have a table of employees and you want to display them sorted by their last names, you would use a query like:

```sql

SELECT * FROM employees

ORDER BY last_name ASC;

```

This will present the records sorted by the `last_name` field in ascending order.

The other keywords are used for different purposes in SQL. "GROUP BY" is used to group rows that have the same values in specified columns into summary rows. "FILTER" is not a standard SQL keyword; it is applied in certain contexts (like in window functions) but not for sorting records. "HAVING" is used to filter results after aggregation has occurred, specifically with GROUP BY results. Thus, "ORDER BY" is the correct choice when it comes to sorting fields in SQL queries.

Get further explanation with Examzify DeepDiveBeta

FILTER

HAVING

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy