1Z0-171 Database 23ai SQL Certified Associate Practice Questions
Prepare for 1Z0-171 with more than an answer.
- 1
You need to retrieve the top 5 earners from the
EMPLOYEEStable. If there is a tie for the 5th position, you want to include all tied rows. Which FETCH clause syntax should you use?Show answer details
Correct answer: D
The
WITH TIESoption ensures that if the Nth row (5th in this case) has the same sort key value as subsequent rows, those subsequent rows are also returned. - 2
You want to create a report that lists all employees and their managers. The result should include employees who do not have a manager (like the CEO). Which type of join is best suited for this requirement?
Show answer details
Correct answer: D
A Self Join matches rows within the same table. To include employees without managers (where manager_id is NULL), you must use a Left Outer Join starting from the Employee side of the relation.
- 3
Which two statements about the
ROUNDandTRUNCfunctions applied to DATE values are true? (Select TWO)Show answer details
Correct answer: A, B
TRUNC with 'YEAR' sets the date to January 1st of the current year, resetting time to midnight.
ROUND on dates uses the midpoint. For 'MONTH', the 16th day rounds up to the next month. TRUNC always floors to the start of the specified unit.
- 4
A database consultant is designing a schema for a new inventory system. The system requires a table to store product categories where each category must have a unique numeric identifier that is automatically generated by the database upon insertion. The identifier should not allow gaps if the database restarts, even at the cost of performance. Which DDL strategy fulfills this requirement?
Show answer details
Correct answer: D
To prevent gaps caused by caching during database restarts, the NOCACHE option must be used. The ORDER option ensures values are generated in order of request. GENERATED ALWAYS AS IDENTITY creates an internal sequence to populate the column automatically.
- 5
You are querying the
SALES_DATAtable to generate a report. You need to return the string 'No Commission' for any row where theCOMMISSION_PCTcolumn is NULL. IfCOMMISSION_PCTis not NULL, you must return the commission value converted to a string. Which function is best suited for this specific requirement?Show answer details
Correct answer: A
NVL takes two arguments. If the first is null, it returns the second. Since the second argument is a string literal ('No Commission'), the first argument must also be of character type (or implicitly convertible). Explicitly converting COMMISSION_PCT to CHAR ensures type compatibility.
- 6
Review the following query structure intended to filter employee records.
SELECT employee_id, last_name FROM employees WHERE job_id = 'IT_PROG' OR job_id = 'AD_PRES' AND salary > 15000;Which statement accurately describes how the database interprets the precedence of operators in this query?
Show answer details
Correct answer: D
The AND operator has higher precedence than OR. Therefore,
job_id = 'AD_PRES' AND salary > 15000is evaluated first. The result is then combined withjob_id = 'IT_PROG'using OR.
