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.
Only the first query executes successfully.

B.
Only the second query executes successfully.

C.
Both queries execute successfully but give different results.

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

Explanation:
Note: You cannot use column alias in the WHERE clause.



Leave a Reply 7

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


Jason

Jason

must be something wrong here

Fj

Fj

there are no where clause in both queries, right?

Bina

Bina

FJ the correct reason is, The code in the first query with order by should be “code” not code.

alex6675

alex6675

Both queries will fail, even with “code” in the order by “code”

alex6675

alex6675

Both queries will fail, even with “code” in the order by clause

Justyna

Justyna

First query is something like:
select deptno, dname “dept_name” from dept order by “dept_name”

result:
DEPTNO dept_name
———- ————–
10 ACCOUNTING
40 OPERATIONS
20 RESEARCH
30 SALES

When ‘dept_name’ is without double quotas in caluse ORDER BY then you get error
ORA-00904: “DEPT_NAME”: invalid identifier
because DEPT_NAME is something else than dept_name (small letters).

Second query will be executed and give output:

DEPTNO dept_name
———- ————–
10 ACCOUNTING
20 RESEARCH
30 SALES
40 OPERATIONS

See also comments for the same question in exam 1ZO-051 on this website. It is question 120.

hwfurlan

hwfurlan

Where is the comma between the columns?