Advanced SQL interview questions

78 real Advanced SQL questions from the Data Engineering bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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
Reveal the answer + AI explanation — free account

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.
Reveal the answer + AI explanation — free account

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

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Advanced SQL free