Sign in

Tracks/Window functions

Window functions

RANK, LAG, running totals, and top-N per group.

Start this track
window functions
ROW_NUMBER
RANK
DENSE_RANK
NTILE
LAG
LEAD
FIRST_VALUE
LAST_VALUE
running total
top N per group

0/114 solved

  1. 1—032. Rank Employees by Salary
    medium
  2. 2—033. Daily Running Revenue
    medium
  3. 3—043. First Order per Customer
    medium
  4. 4—044. Dense Rank Products by Price Within Category
    medium
  5. 5—045. Salary Quartiles
    medium
  6. 6—046. Month-over-Month Revenue Change
    medium
  7. 7—047. Preview Next Month Revenue with LEAD
    medium
  8. 8—051. Top 3 Products per Category by Price
    medium
  9. 9—053. Revenue Share per Category
    medium
  10. 10—054. Year-over-Year Order Revenue Growth
    medium
  11. 11—055. First Purchase Amount per Customer
    medium
  12. 12—056. Most Recent Order per Customer
    medium
  13. 13—059. Second Highest Salary
    medium
  14. 14—061. Cumulative Revenue Percentage by Department
    medium
  15. 15—065. Category Revenue Summary (Chained CTEs)
    medium
  16. 16—069. 7-Day Rolling Active Users
    medium
  17. 17—071. Rank Departments by Total Payroll
    medium
  18. 18—075. Average Days Between Customer Orders
    medium
  19. 19—077. Deduplicate Rows with ROW_NUMBER
    medium
  20. 20—080. 3-Month Moving Average Revenue
    medium
  21. 21—081. Account Running Balance
    medium
  22. 22—083. Find Gaps in Sequential Order IDs
    medium
  23. 23—087. Third Highest Salary
    medium
  24. 24—161. Row Number Within Each Department
    medium
  25. 25—162. Rank Sales Representatives with Ties
    medium
  26. 26—163. Game Leaderboard with Dense Rank
    medium
  27. 27—164. Month-over-Month Revenue Change Using LAG
    medium
  28. 28—165. Time Until Next Customer Event Using LEAD
    medium
  29. 29—166. Salary Quartile Buckets Using NTILE
    medium
  30. 30—167. Percentile Rank of Exam Scores
    medium
  31. 31—168. Cumulative Distribution of Product Prices
    medium
  32. 32—169. Department Max and Min Salary Using FIRST_VALUE and LAST_VALUE
    medium
  33. 33—170. Running Total of Daily Sales
    medium
  34. 34—171. 3-Day Moving Average of Stock Closing Price
    medium
  35. 35—172. Count Orders Per Customer Without GROUP BY
    medium
  36. 36—173. Compare Each Product Price to Its Category Min and Max
    medium
  37. 37—177. Chained CTEs for Layered Sales Analysis
    medium
  38. 38—192. Find Consecutive Activity Streaks (Islands Problem)
    medium
  39. 39—193. Deduplicate Orders Keeping the Latest Entry
    medium
  40. 40—194. Top 2 Products Per Category by Revenue
    medium
  41. 41—195. Each Sale as a Percentage of Total Revenue
    medium
  42. 42—206. Year-over-Year Revenue Growth Using LAG
    medium
  43. 43—207. Month-over-Month Revenue Growth Rate
    medium
  44. 44—210. Funnel Analysis with Step-by-Step Conversion Rates
    medium
  45. 45—211. ABC Inventory Classification by Cumulative Revenue
    medium
  46. 46—212. Customer Tier Segmentation Using NTILE
    medium
  47. 47—213. Revenue Concentration — Cumulative % Per Customer
    medium
  48. 48—215. Find the Most Frequently Occurring Rating (Mode)
    medium
  49. 49—218. Rolling 7-Day Revenue Sum
    medium
  50. 50—224. Multiple Window Functions in One Query
    medium
  51. 51—225. Running Maximum with RANGE BETWEEN UNBOUNDED PRECEDING
    medium
  52. 52—226. Monthly Session Counts with Date-Based Partition
    medium
  53. 53—227. Named Window Using the WINDOW Clause
    medium
  54. 54—230. Revenue Share per Category Using Window SUM
    medium
  55. 55—231. Compare Each Employee to Their Department Average Salary
    medium
  56. 56—232. Detect Price Changes Using LAG
    medium
  57. 57—233. Days Until Next Event Using LEAD
    medium
  58. 58—235. Employees in Top 10% by Salary Using PERCENT_RANK
    medium
  59. 59—237. Rank Products Within Each Brand by Price
    medium
  60. 60—246. Longest Gap Between Consecutive Orders per Customer
    medium
  61. 61—251. RFM Analysis — Recency, Frequency, Monetary Buckets
    medium
  62. 62—261. Remove Duplicates Keeping the Most Recent Record
    medium
  63. 63—271. Assign Row Numbers Within Department Groups
    medium
  64. 64—274. Finding Maximum Streak of Consecutive Login Days
    medium
  65. 65—275. Customer Segments by Spending Quartile
    medium
  66. 66—276. Product Categories with Month-over-Month Revenue Decline
    medium
  67. 67—279. Cumulative Sum That Resets on Partition Change
    medium
  68. 68—280. Multi-Step CTE Pipeline for Complex Analytics
    medium
  69. 69—331. Customers With Strictly Increasing Order Values
    medium
  70. 70—332. Rank Products by Revenue Within Each Category
    medium
  71. 71—335. Top-Selling Product in Each Region
    medium
  72. 72—336. Employee Salary Growth Over Time
    medium
  73. 73—339. Detect Same-Direction Price and Quantity Changes
    medium
  74. 74—340. Cumulative Order Count per Region
    medium
  75. 75—341. Salary Percentile Rank Within Department
    medium
  76. 76—344. Top Salesperson Each Quarter
    medium
  77. 77—349. Revenue From First-Time vs Repeat Purchases
    medium
  78. 78—350. 7-Day Rolling Order Count
    medium
  79. 79—351. Most Popular Product Each Month
    medium
  80. 80—352. Customers Who Upgraded Their Loyalty Tier
    medium
  81. 81—354. Category Market Share of Total Revenue
    medium
  82. 82—360. Median Days Between Customer Purchases
    medium
  83. 83—362. Monthly Revenue With Simple Growth Forecast
    medium
  84. 84—365. Month-Over-Month Revenue Trend by Category
    medium
  85. 85—366. Time Between Order Status Transitions
    medium
  86. 86—370. Peak Order Hour per Day
    medium
  87. 87—371. Regional Sales Rep Performance with Rank
    medium
  88. 88—373. Win-Back: Customers Who Returned After 90-Day Dormancy
    medium
  89. 89—092. Longest Consecutive Login Streak
    hard
  90. 90—093. Median Salary Without PERCENTILE
    hard
  91. 91—095. Session Identification from Login Events
    hard
  92. 92—097. Cohort Retention Matrix (Months 0–3)
    hard
  93. 93—099. Running Balance with Overdraft Detection
    hard
  94. 94—100. Employee Hierarchy Depth
    hard
  95. 95—283. Graph Shortest Path via BFS
    hard
  96. 96—285. Sliding 30-Day Revenue Window per Customer
    hard
  97. 97—286. Session Stitching with 30-Minute Gap Tolerance
    hard
  98. 98—287. Merge Overlapping Subscription Intervals
    hard
  99. 99—291. Busiest 3 Consecutive Days by Revenue
    hard
  100. 100—292. Median Salary by Department using PERCENTILE_CONT
    hard
  101. 101—295. Cohort Retention Analysis Pipeline
    hard
  102. 102—296. Nearest Price Match Across Two Catalogs
    hard
  103. 103—297. Balanced Task Distribution with NTILE
    hard
  104. 104—299. Weighted Composite Product Ranking
    hard
  105. 105—300. Maximum Concurrent Bookings per Room
    hard
  106. 106—381. Maximum Non-Overlapping Meetings
    hard
  107. 107—384. Point-in-Time Price from SCD Type 2 History
    hard
  108. 108—389. First, Last, and Linear Touch Attribution
    hard
  109. 109—392. Revenue-Maximizing Price per Product
    hard
  110. 110—393. Checkout Funnel Drop-Off Rates
    hard
  111. 111—395. Intraday Time-Weighted Average Price
    hard
  112. 112—396. Exponential Moving Average with Alpha 0.3
    hard
  113. 113—397. Nearest Neighbor by Euclidean Distance
    hard
  114. 114—400. Monthly Revenue and New-Customer Dashboard
    hard