Oracle Database Sql Certified Associate · Free Practice Question Easy
Question 22
View and examine the following available responses.
Indicate the query which will create a projection of the ENAME and DEPTNO columns from the EMPLOYEES table.
-
A
- SELECT ename, deptno, dept_location
- FROM employees;
-
B
- SELECT ename AS "employee_name
- FROM employees;
-
C
- SELECT ename, deptno
- FROM emp;
-
D
- SELECT ename, deptno
- FROM employees;
Reveal correct answer
Correct answer: D
Explanation
Projection means a SELECT query.
Evaluate each query to determine which one correctly creates a projection of the ENAME and DEPTNO columns from the EMPLOYEES table.
Correct Answer:
- SELECT ename, deptno
- FROM employees;
This correctly selects (i.e., projects) only the
enameanddeptnocolumns from theemployeestable.Syntax is valid.
Matches the question exactly.
The only correct query that produces a valid projection of the
ENAMEandDEPTNOcolumns from theEMPLOYEEStable.
Incorrect Options:
- SELECT ename, deptno
- FROM emp;
Table name is
emp, notemployees, so not correct unlessempis an alias (which it isn’t here).
- SELECT ename, deptno, dept_location
- FROM employees;
This selects an extra column (
dept_location) — not just a projection ofenameanddeptno.
- SELECT ename AS "employee_name
- FROM employees;
Missing closing quote on the alias
"employee_name. This will cause a syntax error.
A. This query is incorrect because it includes the 'dept_location' column in the projection, which is not specified in the question. It should only project the 'ENAME' and 'DEPTNO' columns.
B. This query is incorrect because it has a syntax error in the column alias for 'ENAME'. The alias is missing the closing double quotation mark, which would result in a syntax error when executed.
C. This query is incorrect because it references the table as 'emp' instead of 'employees' and may result in a table or view not found error.
D. This query is correct as it selects the 'ENAME' and 'DEPTNO' columns from the 'employees' table, which matches the requirement of creating a projection of those specific columns.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
