You need to generate a list of all customer last names with their credit limits from the CUSTOMERS
table.
Those customers who do not have a credit limit should appear last in the list.
Which two queries would achieve the required result? (Choose two.)
A.
SELECT cust_last_name, cust_credit_limit
FROM customers
ORDER BY cust_credit_limit DESC ;
B.
SELECT cust_last_name, cust_credit_limit
FROM customers
ORDER BY cust_credit_limit;
C.
SELECT cust_last_name, cust_credit_limit
FROM customers
ORDER BY cust_credit_limit NULLS LAST;
D.
SELECT cust_last_name, cust_credit_limit
FROM customers
ORDER BY cust_last_name, cust_credit_limit NULLS LAST;
Explanation:
If the ORDER BY clause is not used, the sort order is undefined, and the Oracle server may not
fetch rows in the same order for the same query twice. Use the ORDER BY clause to display the
rows in a specific order.
Note: Use the keywords NULLS FIRST or NULLS LAST to specify whether returned rows
containing null values should appear first or last in the ordering sequence.
ANSWER C Sorting
The default sort order is ascending:
– Numeric values are displayed with the lowest values first (for example, 1 to 999).
– Date values are displayed with the earliest value first (for example, 01-JAN-92 before 01-JAN-95).
– Character values are displayed in the alphabetical order (for example, “A” first and “Z” last).
– Null values are displayed last for ascending sequences and first for descending sequences.
ANSWER B
– You can also sort by a column that is not in the SELECT list.