nerdexam
Oracle

1Z0-061 · Question #285

View the Exhibit and examine the structure of the PRODUCTS table. You want to display only those product names with their list prices where the list price is at least double the minimum price. The…

The correct answer is A. ORDER BY prod_list_price DESC, prod_name; E. ORDER BY prod_list_price DESC, prod_name DESC. Using the ORDER BY Clause The order of rows that are returned in a query result is undefined. The ORDER BY clause can be used to sort the rows. However, if you use the ORDER BY clause, it must be the last clause of the SQL statement. Further, you can specify an expression, an…

Restricting and Sorting Data

Question

View the Exhibit and examine the structure of the PRODUCTS table. You want to display only those product names with their list prices where the list price is at least double the minimum price. The report should start with the product name having the maximum list price satisfying this condition. Evaluate the following SQL statement:

SQL>SELECT prod_name, prod_list_price FROM products WHERE prod_list_price >= 2 * prod_min_price Which ORDER BY clauses can be added to the above SQL statement to get the correct output? (Choose all that apply.)

Options

  • AORDER BY prod_list_price DESC, prod_name;
  • BORDER BY (2*prod_min_price)DESC, prod_name;
  • CORDER BY prod_name, (2*prod_min_price)DESC;
  • DORDER BY prod_name DESC, prod_list_price DESC;
  • EORDER BY prod_list_price DESC, prod_name DESC;

How the community answered

(35 responses)
  • A
    83% (29)
  • B
    3% (1)
  • C
    3% (1)
  • D
    11% (4)

Explanation

Using the ORDER BY Clause The order of rows that are returned in a query result is undefined. The ORDER BY clause can be used to sort the rows. However, if you use the ORDER BY clause, it must be the last clause of the SQL statement. Further, you can specify an expression, an alias, or a column position as the sort condition. [WHERE condition(s)] [ORDER BY {column, expr, numeric_position} [ASC|DESC]]; ORDER BY specifies the order in which the retrieved rows are displayed ASC orders the rows in ascending order (This is the default order.) DESC orders the rows in descending order 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.

Topics

#ORDER BY#sorting#DESC#expression sorting

Community Discussion

No community discussion yet for this question.

Full 1Z0-061 Practice