Back to problems

SQL Interview Questions (Window Functions and CTE)

SQL · Amazon · Hard

Problem Write three standalone SQL queries for common data-analysis tasks. Use at least one CTE and an appropriate window function in each query, such as ROW_NUMBER(), RANK(), LAG(), LEAD(), or SUM() OVER. For every query, explain why you chose its window-function PARTITION BY and ORDER BY columns. The statements should run against the following tables: Assume identifiers are unique within their respective tables, salaries and order amounts are nonnegative, and an order…

Checking your access…