QuizzesLATERAL JOIN / CROSS APPLY — Concept Check
intermediate
sql

LATERAL JOIN / CROSS APPLY — Concept Check

Questions on LATERAL JOIN / CROSS APPLY. A LATERAL join allows a subquery in the FROM clause to reference columns from preceding table expressions, enabling row-dependent subqueries such as top-N per group.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on LATERAL JOIN / CROSS APPLY — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You need to retrieve the top 2 highest-paid employees per department from a database. Which SQL feature allows you to do this efficiently without window functions?

    • AINNER join
    • BLATERAL join
    • CGROUP BY clause
    • DFULL OUTER join
  2. 2.A developer uses a LATERAL join to fetch the top 5 most recent transactions per customer. What happens if a customer has fewer than 5 transactions?

    • AThe query returns NULL for the missing transactions.
    • BThe query fails with an error.
    • CThe query returns no transactions for that customer.
    • DThe query returns all available transactions for that customer.
  3. 3.In a PostgreSQL database, which feature allows a subquery to reference columns from a preceding table in the FROM clause?

    • ACROSS JOIN
    • BLATERAL join
    • CUNION ALL
    • DGROUP BY
  4. 4.A query using LEFT JOIN LATERAL returns some rows with NULL values in the subquery columns. What does this indicate?

    • AThe database connection is lost.
    • BThe left table rows have no matching subquery results.
    • CThe subquery is returning too many rows.
    • DThe query has a syntax error.
  5. 5.Which SQL feature would you use to call a set-returning function for each row in a table?

    • ALATERAL join
    • BGROUP BY
    • CINNER join
    • DRIGHT JOIN
  6. 6.A developer wants to use CROSS APPLY in SQL Server to get the top 3 products by sales per category. What is the equivalent in PostgreSQL?

    • ALATERAL join
    • BFULL OUTER join
    • CINNER join
    • DNATURAL join
  7. 7.Which scenario best illustrates the use of LATERAL for performance optimization?

    • ACalculating average sales per month.
    • BRetrieving the top 10 scores per player in a gaming database.
    • CCounting total sales per region.
    • DListing all employees in alphabetical order.