Which ORDER BY clauses can be added to the above SQL st…

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.)

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.)

A.
ORDER BY prod_list_price DESC, prod_name;

B.
ORDER BY (2*prod_min_price)DESC, prod_name;

C.
ORDER BY prod_name, (2*prod_min_price)DESC;

D.
ORDER BY prod_name DESC, prod_list_price DESC;

E.
ORDER BY prod_list_price DESC, prod_name DESC;

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.
Syntax
SELECT expr
FROM table
[WHERE condition(s)]
[ORDER BY {column, expr, numeric_position} [ASC|DESC]];
In the syntax:
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.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Hola

Hola

Because the right answers put List Price first
A&E