Which statement is true regarding the execution of the above queries?

View the Exhibit and examine the data in the PROMO_CATEGORY and PROMO_COST
columns of the PROMOTIONS table. Evaluate the following two queries: SQL>SELECT
DISTINCT promo_category to_char(promo_cost)”code” FROM promotions ORDER BY
code; SQL>SELECT DISTINCT promo_category promo_cost “code” FROM promotions
ORDER BY 1; Which statement is true regarding the execution of the above queries?

View the Exhibit and examine the data in the PROMO_CATEGORY and PROMO_COST
columns of the PROMOTIONS table. Evaluate the following two queries: SQL>SELECT
DISTINCT promo_category to_char(promo_cost)”code” FROM promotions ORDER BY
code; SQL>SELECT DISTINCT promo_category promo_cost “code” FROM promotions
ORDER BY 1; Which statement is true regarding the execution of the above queries?

A.
Both queries execute successfully and give the same result.

B.
Both queries execute successfully but give different results.

C.
Only the first query executes successfully.

D.
Only the second query executes successfully.

Explanation:



Leave a Reply 4

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


kamil

kamil

Second query can not be performed

Norro

Norro

Correct Answer is D: Only the second query executes successfully.

Query 1: SELECT DISTINCT promo_category, to_char(promo_cost) “code” FROM promotions ORDER BY code;

Outpout: ORA-00904: “CODE”: invalid identifier

Query 2: SELECT DISTINCT promo_category, promo_cost “code” FROM promotions ORDER BY 1

Output:

PROMO_CATEGORY PROMO_COST
internet 98200
internet 98700
magazine 98400
newspaper 98500
newspaper 97800
post 98000
post 99000
radio 97200
radio 99100
TV 98300
TV 97600

Norro

Norro

SELECT DISTINCT promo_category, to_char(promo_cost) “code” FROM promotions ORDER BY code; — ORA-00904: “CODE”: invalid identifier

SELECT DISTINCT promo_category, to_char(promo_cost) “code” FROM promotions ORDER BY”code”; — Works as expected
SELECT DISTINCT promo_category, to_char(promo_cost) “CODE” FROM promotions ORDER BY code; — Works as expected

SELECT DISTINCT promo_category, promo_cost “code” FROM promotions ORDER BY 1; — Works as expected