Q1
True / FalseA subquery in PostgreSQL can be used in the SELECT clause of an SQL statement.
Subqueries can be used in various parts of an SQL statement, including the SELECT clause, to compute a value for each row selected.
Q2
True / FalseSubqueries in PostgreSQL can only return a single value.
Subqueries can return a single value (scalar subqueries), a single row, or multiple rows and columns.
Q3
True / FalseIn PostgreSQL, a subquery can be used within a WHERE clause to filter records.
Subqueries are often used in the WHERE clause to filter records based on the results of the subquery.
Q4
True / FalseIn PostgreSQL, you can use a subquery in the FROM clause to create a temporary table for the main query.
Subqueries in the FROM clause are known as derived tables and can be used to provide a result set that the main query can use as a temporary table.
Q5
True / FalsePostgreSQL does not support correlated subqueries.
PostgreSQL supports correlated subqueries, which are subqueries that reference columns from the outer query.
Q6
True / FalseA subquery in PostgreSQL cannot use the ORDER BY clause.
Subqueries can use the ORDER BY clause when used with LIMIT, OFFSET, or in certain contexts, but not all usages of ORDER BY in subqueries are meaningful or supported.
Q7
True / FalseIn PostgreSQL, a subquery can be used with the EXISTS operator to check for the existence of rows.
The EXISTS operator in PostgreSQL is used with a subquery to test for the existence of rows that meet the specified criteria.
Q8
True / FalseSubqueries in PostgreSQL can be nested up to an unlimited number of levels.
While PostgreSQL supports nested subqueries, the practical limit depends on factors like memory and processing power, and overly complex nesting can lead to performance issues.
Q9
True / FalseIn PostgreSQL, a subquery used in the SELECT clause must always return a single row.
A subquery in the SELECT clause must return a single row with a single column, otherwise, it will result in an error.
Q10
True / FalseIn PostgreSQL, using subqueries can sometimes be optimized by the query planner to improve performance.
The PostgreSQL query planner can optimize certain subqueries to improve performance, such as transforming subqueries into joins or other operations when beneficial.