Oracle Database Sql Certified Associate · Free Practice Question Medium

Question 11

View and examine the following available responses.

Indicate the statement that is true regarding the ordering of data in a SELECT statement.

  • A

    By default numeric values are displayed in descending order.

  • B

    When sorting on character data, the values are case-sensitive.

  • C

    NULL values are not considered by the ORDER BY clause.

  • D

    You cannot ORDER BY a column that is not stated in the SELECT clause.

Reveal correct answer

Correct answer: B

Explanation

The correct statement is: When sorting on character data, the values are case-sensitive.


1. "When sorting on character data, the values are case-sensitive."

  • True

  • In most SQL implementations (like Oracle), sorting is case-sensitive by default.

  • Regardless of the fact that the SQL language is case-insensitive the data is not.

  • Uppercase letters are sorted before lowercase ones (e.g., 'APPLE' before 'apple').

  • When sorting character data, lowercase and uppercase characters are treated differently by the ORDER BY clause.

2. "NULL values are not considered by the ORDER BY clause."

  • False

  • NULL values are included in sorting.

  • By default:

    • In ascending order, NULL values appear last.

    • In descending order, NULL values appear first.

    • This can be customized using NULLS FIRST or NULLS LAST.

3. "You cannot ORDER BY a column that is not stated in the SELECT clause."

  • False

  • You can order by columns not included in the SELECT list.

  • This is valid SQL and commonly used for internal sorting while limiting displayed data.

4. "By default numeric values are displayed in descending order."

  • False

  • The default sort order is ascending (from smallest to largest).

A. Numeric values are displayed in ascending order by default in a SELECT statement. To display them in descending order, you need to explicitly specify the DESC keyword in the ORDER BY clause.

B. When sorting on character data, the values are case-sensitive by default. This means that uppercase and lowercase letters are considered different when ordering the data.

C. NULL values are considered by the ORDER BY clause and can be sorted either in ascending or descending order based on the specified sorting direction.

D. You can ORDER BY a column that is not stated in the SELECT clause as long as it is included in the FROM clause and is accessible in the query.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need