Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free Oracle Database SQL 1Z0-071 Exam Questions

Last updated: · 11 practice questions with answers and explanations

Page: 1 / 22 Total 326 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Retrieving Data using the SQL SELECT Statement

Skill tested: Format projected columns with aliases, concatenation, DISTINCT, and arithmetic expressions.

A sales operations team needs a report with one row per distinct product and its displayed price after a 7% increase. The report must show the product name followed by its category in parentheses, label the computed price as LIST_PRICE, and avoid duplicate product-and-category combinations. The PRODUCT table contains PRODUCT_NAME, CATEGORY, and PRICE. Which query meets all requirements?

Correct Answer: A. SELECT DISTINCT product_name || ' (' || category || ')' AS product, price * 1.07 AS list_price FROM product;
Explanation:

DISTINCT applies to the complete selected row, so the concatenated product-and-category value together with the computed price is deduplicated. Multiplying by 1.07 increases the price by 7%, and the expression alias labels the result. In B, DISTINCT cannot be placed before only one select-list expression in that position. C adds 0.07 currency units rather than increasing the price by 7%. D returns separate columns instead of the requested combined display.

Question 2

New Single answer

Topic: Restricting and Sorting Data

Skill tested: Apply SQL operator precedence and parentheses to filter the intended rows.

A support manager wants an exception list of orders placed during 2024. Include orders with status 'OPEN' or 'PENDING' only when their total exceeds 500; orders with either status but a total of 500 or less must be excluded. The ORDERS table stores ORDER_DATE, STATUS, and TOTAL. Which WHERE condition correctly expresses the requirement in Oracle SQL?

Correct Answer: D. WHERE order_date >= DATE '2024-01-01' AND order_date < DATE '2025-01-01' AND status IN ('OPEN','PENDING') AND total > 500
Explanation:

The date range uses an inclusive lower bound and exclusive upper bound, thereby including every time on December 31, 2024. IN expresses the two permitted statuses, and the separate AND condition requires TOTAL to exceed 500 for both. In A and D, AND has higher precedence than OR, so rows may bypass one or more intended restrictions. C includes exactly 500 and its upper date bound excludes times after midnight at the start of December 31.

Question 3

New Single answer

Topic: Using Single-Row Functions to Customize Output

Skill tested: Use Oracle date functions to identify rows in a calendar month regardless of time component.

A finance analyst must find invoices issued in March 2025. INVOICE_DATE is a DATE column that may include time-of-day values, and the report must not omit invoices entered at any time on March 31. The analyst also wants the predicate to remain suitable for an index on INVOICE_DATE. Which predicate best satisfies the requirements?

Correct Answer: C. WHERE invoice_date >= DATE '2025-03-01' AND invoice_date < DATE '2025-04-01'
Explanation:

A half-open range includes all March dates and times while excluding April 1. Because the column is not wrapped in a function, an ordinary index on INVOICE_DATE can be used for the range predicate. A compares only the month and would include March from every year while applying a function to the column. B's upper bound represents midnight at the beginning of March 31, omitting later times that day. D applies TRUNC to the column and generally cannot use a normal index as directly as the range condition.

Question 4

New Single answer

Topic: Using Conversion Functions and Conditional Expressions

Skill tested: Convert formatted character dates explicitly and substitute null values with NVL.

A staging table stores ORDER_DAY as character data in the exact format YYYY-MM-DD and DISCOUNT as a nullable numeric column. A report must return each order date as DD-MON-YYYY and calculate NET_AMOUNT as AMOUNT minus the discount, treating a missing discount as zero. The character dates are valid and the session's default date format must not affect results. Which expression set is correct?

Correct Answer: A. TO_CHAR(TO_DATE(order_day, 'YYYY-MM-DD'), 'DD-MON-YYYY'), amount - NVL(discount, 0)
Explanation:

TO_DATE converts the character value using its known input format, and TO_CHAR then formats the resulting DATE for display. NVL(discount, 0) ensures subtraction produces the amount when DISCOUNT is null; otherwise arithmetic with null yields null. A passes character data directly to TO_CHAR, which expects a date or number. C returns a DATE rather than the requested formatted character value and uses the wrong input mask. D relies on a session-dependent implicit conversion and does not handle null discounts.

Question 5

New Single answer

Topic: Reporting Aggregated Data Using Group Functions

Skill tested: Aggregate grouped sales and use HAVING to filter groups by a computed total.

A regional director needs a list of sales representatives whose total booked revenue exceeds 100,000 during the first quarter of 2025. The SALES table contains REP_ID, SALE_DATE, and AMOUNT; AMOUNT is non-null. The output must contain one row per representative and the total revenue. Which query correctly filters representatives after aggregation?

Correct Answer: B. SELECT rep_id, SUM(amount) total_revenue FROM sales WHERE sale_date >= DATE '2025-01-01' AND sale_date < DATE '2025-04-01' GROUP BY rep_id HAVING SUM(amount) > 100000;
Explanation:

WHERE filters individual sales rows to the first quarter before grouping. GROUP BY creates one group per representative, and HAVING filters those groups using the aggregate SUM(amount). A attempts to use an aggregate in WHERE, which Oracle does not allow. C places a non-grouped date column in HAVING and would not correctly perform the row-level date restriction. D neither calculates a total nor selects a valid grouped expression.

Question 6

New Single answer

Topic: Displaying Data from Multiple Tables

Skill tested: Select an outer join that preserves unmatched rows from the required reporting table.

A service company reports every department, including departments with no assigned technicians, alongside the number of technicians in each. DEPARTMENT has a primary key DEPT_ID; TECHNICIAN has DEPT_ID as a nullable foreign key. The report must show zero for departments without technicians and must not create a row for technicians whose department is null. Which query meets these requirements?

Correct Answer: B. SELECT d.dept_id, COUNT(t.technician_id) FROM department d LEFT OUTER JOIN technician t ON t.dept_id = d.dept_id GROUP BY d.dept_id;
Explanation:

A left outer join preserves every department, and COUNT(t.technician_id) counts only matched technician rows because the technician primary key is null in the generated unmatched row. Such departments therefore receive zero. A's inner join omits empty departments. B counts the generated outer-join row and reports one rather than zero for an empty department. D filters out unmatched rows and groups by the technician-side department key, so it cannot report all departments.

Question 7

New Single answer

Topic: Using Subqueries to Solve Queries

Skill tested: Use a correlated subquery with a group function to compare values against each department average.

A human-resources report must list employees whose salary is greater than the average salary of their own department. EMPLOYEE contains EMPLOYEE_ID, DEPARTMENT_ID, and SALARY. Employees with a null department must not appear, and departments with a single employee should include that employee only if the comparison is true. Which query correctly expresses this rule?

Correct Answer: C. SELECT e.employee_id FROM employee e WHERE e.department_id IS NOT NULL AND e.salary > (SELECT AVG(x.salary) FROM employee x WHERE x.department_id = e.department_id);
Explanation:

The inner query correlates its department to the current outer employee, so AVG is calculated separately for that employee's department. The explicit non-null department condition excludes employees whose department is null. In a one-person department, that employee's salary equals the average and is not greater, as required by the comparison. A compares against the company-wide average. C averages other departments instead. D uses SALARY without grouping or aggregating it appropriately in the HAVING clause.

Question 8

New Single answer

Topic: Using SET Operators

Skill tested: Combine compatible result sets with MINUS and sort the final set correctly.

A compliance analyst needs employee IDs for people who are currently assigned to a project but have not submitted any expense report. PROJECT_ASSIGNMENT and EXPENSE_REPORT each contain EMPLOYEE_ID, and duplicate rows may exist in either table. The final list must contain unique IDs in ascending order. Which query is valid and meets the requirement?

Correct Answer: B. SELECT employee_id FROM project_assignment MINUS SELECT employee_id FROM expense_report ORDER BY employee_id;
Explanation:

MINUS returns distinct rows from its first query that are absent from its second query, matching the requested employees assigned to projects but lacking expense reports. The final ORDER BY belongs after the set operation and sorts the combined result. B places ORDER BY before the set operator, which is not the required query structure. UNION includes IDs from either source rather than excluding those with reports. Oracle's MINUS operator does not use the proposed MINUS ALL syntax.

Question 9

New Single answer

Topic: Managing Tables using DML statements

Skill tested: Use conditional MERGE logic to update existing rows and insert missing rows.

A nightly load stages customer balances in STG_BALANCE, keyed by CUSTOMER_ID, and synchronizes them into CUSTOMER_BALANCE, whose CUSTOMER_ID is unique. For a matching customer, the load must replace the stored balance; for a new customer, it must insert a row. The load must not delete target customers absent from the staging table. Which statement implements the synchronization?

Correct Answer: A. MERGE INTO customer_balance t USING stg_balance s ON (t.customer_id = s.customer_id) WHEN MATCHED THEN UPDATE SET t.balance = s.balance WHEN NOT MATCHED THEN INSERT (customer_id, balance) VALUES (s.customer_id, s.balance);
Explanation:

MERGE matches rows using CUSTOMER_ID, updates the target balance for matches, and inserts staging rows that have no match. It leaves target rows without a staging counterpart untouched, satisfying the no-delete constraint. B reverses the matched and unmatched actions. C can fail when unmatched scalar subqueries return null and its insert can violate the unique key for existing customers. D adds an unnecessary and unsuitable delete clause rather than simply preserving unmatched target rows.

Question 10

New Single answer

Topic: Managing Indexes Synonyms and Sequences

Skill tested: Define a sequence with suitable increment and bounds for generating surrogate keys.

An application inserts one record at a time into a table whose numeric primary key must be generated by the database. Keys must begin at 1000, increase by one, never cycle or wrap around, and remain below 1,000,000. Concurrent sessions may insert records, and occasional gaps are acceptable. Which sequence definition best satisfies these requirements?

Correct Answer: C. CREATE SEQUENCE record_seq START WITH 1000 INCREMENT BY 1 MINVALUE 1000 MAXVALUE 999999 NOCYCLE CACHE 20;
Explanation:

The definition starts at 1000, increments by one, sets the required lower and upper bounds, and uses NOCYCLE so values are not reused after reaching the maximum. Caching values is compatible with concurrent use; it can result in gaps, which the scenario allows. B cycles and eventually reuses values. C permits values below 1000 if the sequence is altered or restarted at its minimum, and ORDER is not needed for unique sequence values. D specifies an invalid zero increment.

Question 11

New Single answer

Topic: Use DDL to manage tables and their relationships

Skill tested: Add an enabled foreign-key constraint to enforce referential integrity between related tables.

A logistics database already contains SHIPMENT and CUSTOMER tables. CUSTOMER.CUSTOMER_ID is a primary key, and SHIPMENT.CUSTOMER_ID has existing values that all correspond to customers. New shipments must not reference nonexistent customers, and deleting a customer with dependent shipments must be prevented. The column should remain nullable because some shipments are not yet assigned. Which DDL statement enforces these requirements without making the relationship mandatory for every shipment?

Correct Answer: C. ALTER TABLE shipment ADD CONSTRAINT shipment_customer_fk FOREIGN KEY (customer_id) REFERENCES customer(customer_id);
Explanation:

An enabled foreign-key constraint permits null values but requires every non-null SHIPMENT.CUSTOMER_ID to match a CUSTOMER primary key. With no ON DELETE action specified, deleting a referenced customer is prevented while dependent shipments exist. B would delete dependent shipments when a customer is deleted, contrary to the requirement. C makes assignment mandatory but does not prevent invalid customer IDs. D creates an index that may improve access, but it does not enforce referential integrity.