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.
must be something wrong here
there are no where clause in both queries, right?
FJ the correct reason is, The code in the first query with order by should be “code” not code.
Both queries will fail, even with “code” in the order by “code”
Both queries will fail, even with “code” in the order by clause
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.
Where is the comma between the columns?