Advanced SQL interview questions

78 Advanced SQL questions from the Data Engineering bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.

Free to start: the 2-minute IT readiness check — six questions and a result.

Take the free IT readiness check

or take a mock interview set up for this area

1. What does LATERAL do?

Mid
  1. A.Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.
  2. B.The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  3. C.Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.
  4. D.SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.

Answer + AI explanation with Pro

2. Which command will Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.?

Mid
  1. A.window frame
  2. B.FILTER
  3. C.NULLIF
  4. D.LATERAL

Answer + AI explanation with Pro

3. Which statement is correct?

Mid
  1. A.LATERAL — Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.
  2. B.LATERAL — Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.
  3. C.LATERAL — The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  4. D.LATERAL — SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.

Answer + AI explanation with Pro

4. What does CROSS JOIN LATERAL do?

Mid
  1. A.Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.
  2. B.Snowflake table function that explodes a VARIANT, ARRAY, or OBJECT into rows, the semi-structured-data equivalent of unnesting.
  3. C.Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.
  4. D.Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.

Answer + AI explanation with Pro

5. Which command will Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.?

Mid
  1. A.RECURSIVE CTE
  2. B.NULLIF
  3. C.CROSS JOIN LATERAL
  4. D.PIVOT

Answer + AI explanation with Pro

6. Which statement is correct?

Mid
  1. A.CROSS JOIN LATERAL — The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  2. B.CROSS JOIN LATERAL — SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.
  3. C.CROSS JOIN LATERAL — Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.
  4. D.CROSS JOIN LATERAL — Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.

Answer + AI explanation with Pro

7. What does UNNEST do?

Mid
  1. A.Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.
  2. B.Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.
  3. C.Function returning the first non-null argument from a list, used to supply defaults and combine fallback columns.
  4. D.Snowflake table function that explodes a VARIANT, ARRAY, or OBJECT into rows, the semi-structured-data equivalent of unnesting.

Answer + AI explanation with Pro

8. Which command will Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.?

Mid
  1. A.NULLIF
  2. B.FILTER
  3. C.PIVOT
  4. D.UNNEST

Answer + AI explanation with Pro

9. Which statement is correct?

Mid
  1. A.UNNEST — Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.
  2. B.UNNEST — Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.
  3. C.UNNEST — The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  4. D.UNNEST — Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.

Answer + AI explanation with Pro

10. What does FLATTEN do?

Mid
  1. A.Snowflake table function that explodes a VARIANT, ARRAY, or OBJECT into rows, the semi-structured-data equivalent of unnesting.
  2. B.A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.
  3. C.Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.
  4. D.Function returning the first non-null argument from a list, used to supply defaults and combine fallback columns.

Answer + AI explanation with Pro

11. Which command will Snowflake table function that explodes a VARIANT, ARRAY, or OBJECT into rows, the semi-structured-data equivalent of unnesting.?

Mid
  1. A.UNNEST
  2. B.FILTER
  3. C.FLATTEN
  4. D.RECURSIVE CTE

Answer + AI explanation with Pro

12. Which statement is correct?

Mid
  1. A.FLATTEN — Snowflake table function that explodes a VARIANT, ARRAY, or OBJECT into rows, the semi-structured-data equivalent of unnesting.
  2. B.FLATTEN — Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.
  3. C.FLATTEN — Function returning the first non-null argument from a list, used to supply defaults and combine fallback columns.
  4. D.FLATTEN — Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.

Answer + AI explanation with Pro

13. What does MATCH_RECOGNIZE do?

Senior
  1. A.Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.
  2. B.SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.
  3. C.Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.
  4. D.Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.

Answer + AI explanation with Pro

14. Which command will SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.?

Senior
  1. A.CROSS JOIN LATERAL
  2. B.FLATTEN
  3. C.MATCH_RECOGNIZE
  4. D.UNNEST

Answer + AI explanation with Pro

15. Which statement is correct?

Senior
  1. A.MATCH_RECOGNIZE — Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.
  2. B.MATCH_RECOGNIZE — SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.
  3. C.MATCH_RECOGNIZE — Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.
  4. D.MATCH_RECOGNIZE — Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.

Answer + AI explanation with Pro

16. What does PIVOT do?

Mid
  1. A.Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.
  2. B.Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.
  3. C.Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.
  4. D.Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.

Answer + AI explanation with Pro

17. Which command will Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.?

Mid
  1. A.CROSS JOIN LATERAL
  2. B.LATERAL
  3. C.PIVOT
  4. D.RECURSIVE CTE

Answer + AI explanation with Pro

18. Which statement is correct?

Mid
  1. A.PIVOT — A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.
  2. B.PIVOT — Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.
  3. C.PIVOT — The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  4. D.PIVOT — Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.

Answer + AI explanation with Pro

19. What does UNPIVOT do?

Mid
  1. A.Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.
  2. B.Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.
  3. C.Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.
  4. D.Function returning null when its two arguments are equal, commonly used to guard against divide-by-zero by nulling a zero denominator.

Answer + AI explanation with Pro

20. Which command will Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.?

Mid
  1. A.CROSS JOIN LATERAL
  2. B.UNPIVOT
  3. C.window frame
  4. D.MATCH_RECOGNIZE

Answer + AI explanation with Pro

21. Which statement is correct?

Mid
  1. A.UNPIVOT — Operator that rotates columns back into rows, converting a wide cross-tab into long key-value format.
  2. B.UNPIVOT — Function returning null when its two arguments are equal, commonly used to guard against divide-by-zero by nulling a zero denominator.
  3. C.UNPIVOT — A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.
  4. D.UNPIVOT — SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.

Answer + AI explanation with Pro

22. What does RECURSIVE CTE do?

Senior
  1. A.SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.
  2. B.A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.
  3. C.Function returning null when its two arguments are equal, commonly used to guard against divide-by-zero by nulling a zero denominator.
  4. D.Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.

Answer + AI explanation with Pro

23. Which command will A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.?

Senior
  1. A.UNPIVOT
  2. B.NULLIF
  3. C.RECURSIVE CTE
  4. D.PIVOT

Answer + AI explanation with Pro

24. Which statement is correct?

Senior
  1. A.RECURSIVE CTE — A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.
  2. B.RECURSIVE CTE — SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.
  3. C.RECURSIVE CTE — Function returning null when its two arguments are equal, commonly used to guard against divide-by-zero by nulling a zero denominator.
  4. D.RECURSIVE CTE — Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.

Answer + AI explanation with Pro

25. What does FILTER do?

Mid
  1. A.Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.
  2. B.Join that pairs each left row with rows produced by a lateral subquery depending on that row, often used to expand arrays or call table functions per row.
  3. C.A WITH RECURSIVE common table expression that references itself to traverse hierarchies or graphs, such as org charts or bill-of-materials trees.
  4. D.Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.

Answer + AI explanation with Pro

26. Which command will Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.?

Mid
  1. A.PIVOT
  2. B.FLATTEN
  3. C.FILTER
  4. D.RECURSIVE CTE

Answer + AI explanation with Pro

27. Which statement is correct?

Mid
  1. A.FILTER — Operator that rotates distinct values of a column into separate columns, turning long-format rows into a wide cross-tab.
  2. B.FILTER — Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.
  3. C.FILTER — The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  4. D.FILTER — Function returning the first non-null argument from a list, used to supply defaults and combine fallback columns.

Answer + AI explanation with Pro

28. What does window frame do?

Senior
  1. A.Join keyword allowing a subquery on the right side to reference columns from tables on its left, enabling row-by-row correlated joins.
  2. B.Aggregate clause (FILTER (WHERE ...)) applying a per-aggregate condition, a cleaner alternative to CASE expressions inside aggregates.
  3. C.The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  4. D.Function returning the first non-null argument from a list, used to supply defaults and combine fallback columns.

Answer + AI explanation with Pro

29. Which command will The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.?

Senior
  1. A.UNPIVOT
  2. B.RECURSIVE CTE
  3. C.LATERAL
  4. D.window frame

Answer + AI explanation with Pro

30. Which statement is correct?

Senior
  1. A.window frame — The ROWS or RANGE specification defining which rows around the current row a window aggregate sees; RANGE is value-based while ROWS is positional.
  2. B.window frame — SQL clause for row-pattern recognition that matches sequences of rows against a regular-expression-like pattern over an ordered partition, used for sessionization and funnels.
  3. C.window frame — Function returning the first non-null argument from a list, used to supply defaults and combine fallback columns.
  4. D.window frame — Operator that flattens an array or repeated column into one row per element, the standard way to explode nested data in BigQuery and Snowflake.

Answer + AI explanation with Pro

Showing 30 of 78 Advanced SQL questions — the full set, with answers, explanations and an AI tutor on every question, is inside.

Free to start

Start with a free readiness check

Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Advanced SQL question come with Pro.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers