1z0-071 Exam QuestionsBrowse all questions from this exam

1z0-071 Exam - Question 11


Which three are true about scalar subquery expressions? (Choose three.)

Show Answer
Correct Answer: AEF

Scalar subqueries can be nested within other scalar subqueries or within other SQL expressions. A scalar subquery expression that returns zero rows evaluates to NULL. Scalar subqueries cannot be used in GROUP BY clauses because they do not return a single value that can be used to group rows.

Discussion

7 comments
Sign in to comment
zouveOptions: AEF
Jul 5, 2023

A. They can be nested. Scalar subqueries can be nested within other scalar subqueries or within other SQL expressions. E. A scalar subquery expression that returns zero rows evaluates to NULL. If a scalar subquery returns no rows, it evaluates to NULL. F. They cannot be used in GROUP BY clauses. Scalar subqueries cannot be used in GROUP BY clauses because they do not return a single value that can be used to group rows.

Artur1991Options: AEF
Sep 4, 2022

AEF are the correct answers https://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions010.htm

heoj10272
Oct 11, 2022

I agree with you, but this would be better docs. https://docs.oracle.com/database/121/SQLRF/expressions014.htm#SQLRF52093 this is 12c docs.

holdfaststrongly
Oct 12, 2022

According to both of your links, wouldn't B also correct because INSERT is part of a DML statement? B says "CANNOT" be used in the value of an INSERT statement. Double negative makes the statement positive. Just saying...

Chandra1104Options: ABE
Mar 21, 2023

Its ABE. A. They can be nested. --> True B. They cannot be used in the VALUES clause of an INSERT statement. --> True C. A scalar subquery expression that returns zero rows evaluates to zero. --> False D. They can be used as default values for columns in a CREATE TABLE statement.--> False E. A scalar subquery expression that returns zero rows evaluates to NULL. --> True F. They cannot be used in GROUP BY clauses.--> False https://www.oratable.com/scalar-subquery/

J4vi
May 4, 2023

AEF There is no way you could use it in GROUP BY clauses, but it says nothing about VALUES clause. https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Scalar-Subquery-Expressions.html#GUID-475D80C3-C873-4475-AB1A-8837C5CF8CE4

jm9999Options: BEF
Sep 27, 2023

I don't think they can be nested. Tried: select employee_id, (select department_name, (select city from locations l where l.location_id=d.location_id) from departments d where d.department_id=e.department_id) from employees e; But got 'too many values error'.

jm9999
Oct 6, 2023

Changing my answer to AEF. I found B to be incorrect. Still not sure how to nest them (A).

TofOra
Feb 2, 2024

select order_id, order_total_value, (select avg(order_total_value from orders where order_date > (select sysdate - 30 from dual)) as average_30_days, order_total_value - (select avg(order_total_value from orders where order_date > (select sysdate - 30 from dual)) as above_average_30_days from orders where order_total_value > (select avg(order_total_value) from orders where order_date > (select sysdate - 30 from dual))

TofOra
Feb 2, 2024

This query is returning more than 1 row: select city from locations l where l.location_id=d.location_id so 'too many values error', try select DISTINCT city from locations l where l.location_id=d.location_id

Ashkush
Apr 11, 2024

Why is D incorrect?

NSilva
Apr 19, 2024

D. They can be used as default values for columns in a CREATE TABLE statement. >> True, but there might be one of two issues. 1) The website has marked it incorrectly as "False" 2) It is an SQL exam, where wording matters. "You can use it as a default value (IN columns) / (for ROWS) during CREATE TABLE statement"

alelejaja
May 23, 2024

Sorry to say I don't share your point here. D is falso since, as official doc from Oracle highlights, scalar subqueries are not valid expressions as default values for columns. https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Scalar-Subquery-Expressions.html#GUID-475D80C3-C873-4475-AB1A-8837C5CF8CE4

alelejajaOptions: AEF
May 23, 2024

I also think AEF are the correct answers