Sign in

Problems

Filter by difficulty, tag, company, or solved status. Queries run in DuckDB in your browser.

StatusTitleDifficultyTags
—001. Select All Employees
easy
SELECT
—002. Filter Employees by Salary
easy
SELECT
WHERE
—003. Order Employees by Salary
easy
ORDER BY
SELECT
—004. Count Employees
easy
COUNT
aggregate
—005. Employees With Departments
easy
SELECT
INNER JOIN
—006. Distinct Job Titles
easy
SELECT
DISTINCT
—007. Top 5 Highest-Paid Employees
easy
SELECT
ORDER BY
LIMIT
—008. Employees Hired After 2022
easy
SELECT
WHERE
date functions
—009. Employees Without a Manager
easy
SELECT
WHERE
IS NULL
—010. Total Salary Budget
easy
SELECT
SUM
aggregate
—011. Average Product Price
easy
SELECT
AVG
aggregate
—012. Most Expensive Product
easy
SELECT
MAX
aggregate
—013. Cheapest Product
easy
SELECT
MIN
aggregate
—014. Customer Count by Country
easy
SELECT
GROUP BY
COUNT
—015. Products Out of Stock
easy
SELECT
WHERE
—016. Employees With No Department
easy
SELECT
LEFT JOIN
IS NULL
—017. Salary Tier Label
easy
SELECT
CASE
—018. Customer Name Search
easy
SELECT
WHERE
LIKE
—019. Orders in a Price Range
easy
SELECT
WHERE
BETWEEN
—020. Customers from Specific Cities
easy
SELECT
WHERE
IN
—021. Coalesce Missing Department Name
easy
SELECT
COALESCE
LEFT JOIN
—022. Uppercase Product Names
easy
SELECT
string functions
—023. Extract Order Year
easy
SELECT
date functions
EXTRACT
—024. Total Orders per Customer
easy
SELECT
GROUP BY
COUNT
—025. Count Unique Product Categories
easy
SELECT
COUNT
DISTINCT
—026. Orders with Status Pending
easy
SELECT
WHERE
—027. Employees Earning Above 100k
easy
SELECT
WHERE
—028. Sort Products by Price Descending
easy
SELECT
ORDER BY
—029. Paginate Products (Page 3, 5 per page)
easy
SELECT
ORDER BY
LIMIT
—030. Monthly Order Count
easy
SELECT
GROUP BY
date functions
—031. Average Salary by Department
medium
GROUP BY
AVG
aggregate
—032. Rank Employees by Salary
medium
window functions
RANK
ORDER BY
—033. Daily Running Revenue
medium
window functions
SUM
running total
—034. Departments with 3 or More Employees
medium
GROUP BY
HAVING
COUNT
—035. Customers with At Least One Order
medium
SELECT
EXISTS
subquery
—036. Customers with No Orders
medium
SELECT
EXISTS
subquery
—037. Products Never Ordered
medium
SELECT
LEFT JOIN
IS NULL
—038. Employees Earning Above Their Department Average
medium
SELECT
correlated subquery
AVG
—039. Manager Names via Self Join
medium
SELECT
self join
INNER JOIN
—040. Order Line Details
medium
SELECT
INNER JOIN
—041. Top-Earning Departments (CTE)
medium
SELECT
CTE
GROUP BY
—042. Combined List: Employees and Customers Named Alex
medium
SELECT
UNION
WHERE
—043. First Order per Customer
medium
SELECT
ROW_NUMBER
window functions
—044. Dense Rank Products by Price Within Category
medium
SELECT
DENSE_RANK
window functions
—045. Salary Quartiles
medium
SELECT
NTILE
window functions
—046. Month-over-Month Revenue Change
medium
SELECT
LAG
window functions
—047. Preview Next Month Revenue with LEAD
medium
SELECT
LEAD
window functions
—048. All Employees and Departments (Full Outer Join)
medium
SELECT
FULL OUTER JOIN
—049. All Size-Color Combinations (Cross Join)
medium
SELECT
CROSS JOIN
—050. Order Count by Status (Conditional Aggregation)
medium
SELECT
CASE
conditional aggregation
—051. Top 3 Products per Category by Price
medium
SELECT
ROW_NUMBER
window functions
—052. Find Duplicate Customer Emails
medium
SELECT
GROUP BY
HAVING
—053. Revenue Share per Category
medium
SELECT
window functions
SUM
—054. Year-over-Year Order Revenue Growth
medium
SELECT
LAG
CTE
—055. First Purchase Amount per Customer
medium
SELECT
FIRST_VALUE
window functions
—056. Most Recent Order per Customer
medium
SELECT
LAST_VALUE
window functions
—057. Employee Tenure in Full Years
medium
SELECT
date functions
—058. Monthly New Customer Signups
medium
SELECT
GROUP BY
date functions
—059. Second Highest Salary
medium
SELECT
DENSE_RANK
window functions
—060. Employees Sharing the Same Salary
medium
SELECT
self join
GROUP BY
—061. Cumulative Revenue Percentage by Department
medium
SELECT
window functions
SUM
—062. Products with Above-Average Rating
medium
SELECT
subquery
AVG
—063. Count Employees with Missing Salary
medium
SELECT
IS NULL
COUNT
—064. Revenue per Unit Sold (Safe Division with NULLIF)
medium
SELECT
NULLIF
CASE
—065. Category Revenue Summary (Chained CTEs)
medium
SELECT
CTE
GROUP BY
—066. Top-Spending Customers (Derived Table)
medium
SELECT
subquery
GROUP BY
—067. Extract Email Domain
medium
SELECT
string functions
GROUP BY
—068. Revenue by Category and Order Status
medium
SELECT
conditional aggregation
CASE
—069. 7-Day Rolling Active Users
medium
SELECT
window functions
date functions
—070. Products with Zero Total Sales
medium
SELECT
LEFT JOIN
IS NULL
—071. Rank Departments by Total Payroll
medium
SELECT
GROUP BY
SUM
—072. Customer Lifetime Value
medium
SELECT
GROUP BY
SUM
—073. Orders from Last Quarter
medium
SELECT
WHERE
BETWEEN
—074. Products per Category as Comma-Separated List
medium
SELECT
string functions
GROUP BY
—075. Average Days Between Customer Orders
medium
SELECT
LAG
window functions
—076. Monthly Order Completion Rate
medium
SELECT
conditional aggregation
date functions
—077. Deduplicate Rows with ROW_NUMBER
medium
SELECT
ROW_NUMBER
window functions
—078. Customers with High-Value Orders
medium
SELECT
IN
subquery
—079. Customer Cohort by First Order Month
medium
SELECT
CTE
date functions
—080. 3-Month Moving Average Revenue
medium
SELECT
window functions
AVG
—081. Account Running Balance
medium
SELECT
window functions
SUM
—082. Retained Customers: Ordered in Both Month 1 and Month 2
medium
SELECT
INTERSECT
date functions
—083. Find Gaps in Sequential Order IDs
medium
SELECT
gaps and islands
window functions
—084. Custom Sort Priority with CASE in ORDER BY
medium
SELECT
CASE
ORDER BY
—085. Employees Who Share the Same Manager
medium
SELECT
self join
GROUP BY
—086. All Departments Including Empty Ones
medium
SELECT
RIGHT JOIN
GROUP BY
—087. Third Highest Salary
medium
SELECT
DENSE_RANK
window functions
—088. Fulfilled Orders Percentage per Month
medium
SELECT
conditional aggregation
date functions
—089. Category with the Highest Average Price
medium
SELECT
GROUP BY
AVG
—090. Customers Who Ordered Every Month of 2026
medium
SELECT
GROUP BY
HAVING
—091. Managers Paid Above Team Average
hard
self join
CTE
subquery
—092. Longest Consecutive Login Streak
Today
hard
gaps and islands
window functions
date functions
—093. Median Salary Without PERCENTILE
hard
SELECT
correlated subquery
CASE
—094. Org Chart: All Direct and Indirect Reports
hard
SELECT
recursive CTE
—095. Session Identification from Login Events
hard
SELECT
window functions
LAG
—096. Churned vs Retained Customers
hard
SELECT
CTE
date functions
—097. Cohort Retention Matrix (Months 0–3)
hard
SELECT
CTE
conditional aggregation
—098. Frequently Bought Together (Market Basket)
hard
SELECT
self join
COUNT
—099. Running Balance with Overdraft Detection
hard
SELECT
window functions
SUM
—100. Employee Hierarchy Depth
hard
SELECT
recursive CTE
COUNT
—101. String Length Function
easy
SELECT
LENGTH
string functions
—102. UPPER and LOWER String Functions
easy
SELECT
UPPER
LOWER
—103. Trim Leading and Trailing Whitespace
easy
SELECT
TRIM
LTRIM
—104. Concatenate First and Last Name
easy
SELECT
CONCAT
string functions
—105. Extract Category Code from SKU
easy
SELECT
SUBSTRING
string functions
—106. Replace Words in Review Text
easy
SELECT
REPLACE
string functions
—107. Filter Orders by Date
easy
SELECT
WHERE
date functions
—108. Extract Year from Hire Date
easy
SELECT
EXTRACT
date functions
—109. Find Orders Placed in September
easy
SELECT
EXTRACT
date functions
—110. Calculate Project Duration in Days
easy
SELECT
DATEDIFF
date functions
—111. Round Discounted Prices
easy
SELECT
ROUND
math functions
—112. Ceiling and Floor of Order Amounts
easy
SELECT
CEIL
FLOOR
—113. Find Accounts Far from Target Balance
easy
SELECT
ABS
WHERE
—114. Find Products with Quantity Divisible by 3
easy
SELECT
MOD
WHERE
—115. Calculate Square Area and Diagonal
easy
SELECT
POWER
SQRT
—116. Return First Available Phone Number
easy
SELECT
COALESCE
NULL handling
—117. Avoid Division by Zero with NULLIF
easy
SELECT
NULLIF
NULL handling
—118. Find Top-Level Employees with No Manager
easy
SELECT
WHERE
IS NULL
—119. Find Products with a Description
easy
SELECT
WHERE
IS NOT NULL
—120. Filter Employees by Salary Range
easy
SELECT
WHERE
BETWEEN
—121. Filter Products by Category Using IN
easy
SELECT
WHERE
IN
—122. Exclude Cancelled and Returned Orders
easy
SELECT
WHERE
NOT IN
—123. Find Gmail Customers Using LIKE
easy
SELECT
WHERE
LIKE
—124. Match Employee Codes with _ Wildcard
easy
SELECT
WHERE
LIKE
—125. Find Products NOT Starting with S
easy
SELECT
WHERE
NOT LIKE
—126. Filter with Multiple AND Conditions
easy
SELECT
WHERE
AND
—127. Filter with Multiple OR Conditions
easy
SELECT
WHERE
OR
—128. Mix AND and OR with Parentheses
easy
SELECT
WHERE
AND
—129. Total Amount Spent per Customer
easy
SELECT
SUM
GROUP BY
—130. Average Rating per Product
easy
SELECT
AVG
ROUND
—131. Most Recent Hire Date per Department
easy
SELECT
MAX
GROUP BY
—132. First Product Name Alphabetically per Category
easy
SELECT
MIN
GROUP BY
—133. COUNT(*) vs COUNT(column)
easy
SELECT
COUNT
NULL handling
—134. Count Distinct Customers
easy
SELECT
COUNT
DISTINCT
—135. Map Status Codes to Labels with CASE WHEN
easy
SELECT
CASE WHEN
conditional logic
—136. Assign Salary Grade with CASE WHEN Ranges
easy
SELECT
CASE WHEN
conditional logic
—137. Handle NULL Bonus with CASE WHEN
easy
SELECT
CASE WHEN
NULL handling
—138. Sort by Department and Salary
easy
SELECT
ORDER BY
sorting
—139. Sort Products by Profit Margin
easy
SELECT
ORDER BY
arithmetic
—140. Paginate Results with LIMIT and OFFSET
easy
SELECT
LIMIT
OFFSET
—141. Top 5 Orders by Amount Using FETCH FIRST
easy
SELECT
FETCH FIRST
ORDER BY
—142. Rename Columns with AS Alias
easy
SELECT
AS
column alias
—143. Use Table Aliases in a JOIN
easy
SELECT
table alias
INNER JOIN
—144. Calculate Price Including Tax
easy
SELECT
arithmetic
calculated column
—145. Join Orders with Customer Details
easy
SELECT
INNER JOIN
joins
—146. Find Customers Who Have Never Ordered
easy
SELECT
LEFT JOIN
IS NULL
—147. List All Unique Order Statuses
easy
SELECT
DISTINCT
filtering
—148. Find Unique Department-City Combinations
easy
SELECT
DISTINCT
filtering
—149. Count Orders by Status
easy
SELECT
GROUP BY
COUNT
—150. Total Revenue by Department and Quarter
easy
SELECT
GROUP BY
SUM
—151. Customers Who Spent More Than $500
easy
SELECT
HAVING
SUM
—152. Products Ordered by More Than 2 Customers
easy
SELECT
HAVING
COUNT
—153. Group Orders by Month Using DATE_TRUNC
easy
SELECT
DATE_TRUNC
GROUP BY
—154. Find Active Subscriptions After a Date
easy
SELECT
WHERE
CURRENT_DATE
—155. Pad Invoice Numbers with LPAD
easy
SELECT
LPAD
RPAD
—156. Reverse Strings and Detect Palindromes
easy
SELECT
REVERSE
CASE WHEN
—157. Find the Position of @ in Email Addresses
easy
SELECT
POSITION
INSTR
—158. CHAR_LENGTH vs LENGTH on Messages
easy
SELECT
CHAR_LENGTH
LENGTH
—159. Replace NULL Commission with IFNULL
easy
SELECT
IFNULL
NULL handling
—160. Find Employees Earning Above Average Salary
easy
SELECT
subquery
WHERE
—161. Row Number Within Each Department
medium
window functions
ROW_NUMBER
PARTITION BY
—162. Rank Sales Representatives with Ties
medium
window functions
RANK
ORDER BY
—163. Game Leaderboard with Dense Rank
medium
window functions
DENSE_RANK
PARTITION BY
—164. Month-over-Month Revenue Change Using LAG
medium
window functions
LAG
ORDER BY
—165. Time Until Next Customer Event Using LEAD
medium
window functions
LEAD
PARTITION BY
—166. Salary Quartile Buckets Using NTILE
medium
window functions
NTILE
ORDER BY
—167. Percentile Rank of Exam Scores
medium
window functions
PERCENT_RANK
ORDER BY
—168. Cumulative Distribution of Product Prices
medium
window functions
CUME_DIST
ORDER BY
—169. Department Max and Min Salary Using FIRST_VALUE and LAST_VALUE
medium
window functions
FIRST_VALUE
LAST_VALUE
—170. Running Total of Daily Sales
medium
window functions
SUM OVER
ORDER BY
—171. 3-Day Moving Average of Stock Closing Price
medium
window functions
AVG OVER
ROWS BETWEEN
—172. Count Orders Per Customer Without GROUP BY
medium
window functions
COUNT OVER
PARTITION BY
—173. Compare Each Product Price to Its Category Min and Max
medium
window functions
MIN OVER
MAX OVER
—174. Employees Earning Above Their Department Average
medium
correlated subquery
SELECT
WHERE
—175. Customers Who Have Placed at Least One Order
medium
EXISTS
subquery
SELECT
—176. Products That Have Never Been Ordered
medium
NOT EXISTS
subquery
SELECT
—177. Chained CTEs for Layered Sales Analysis
medium
CTE
WITH
GROUP BY
—178. Traverse Org Chart Hierarchy with Recursive CTE
medium
recursive CTE
WITH RECURSIVE
UNION ALL
—179. Combine Customer Lists with UNION ALL vs UNION
medium
UNION ALL
UNION
deduplication
—180. Customers Who Bought Both Online and In-Store
medium
INTERSECT
SET operations
SELECT
—181. Products Not Currently on Sale Using EXCEPT
medium
EXCEPT
SET operations
SELECT
—182. Pivot Quarterly Sales into Columns Using CASE
medium
PIVOT
CASE WHEN
GROUP BY
—183. Unpivot Quarterly Columns to Rows Using UNION ALL
medium
UNPIVOT
UNION ALL
SELECT
—184. Comma-Separated Employee List Per Department
medium
STRING_AGG
GROUP BY
aggregation
—185. Aggregate Products into an Array Per Category
medium
ARRAY_AGG
GROUP BY
aggregation
—186. Extract Fields from a JSON Attributes Column
medium
JSON
json_extract_string
WHERE
—187. Filter Users by Email Pattern Using REGEXP
medium
REGEXP
SIMILAR TO
string functions
—188. Extract Email Domain Using SPLIT_PART
medium
SPLIT_PART
string functions
SELECT
—189. Subscription Expiry and Days Remaining
medium
date arithmetic
INTERVAL
CURRENT_DATE
—190. Fill Date Gaps Using GENERATE_SERIES
medium
GENERATE_SERIES
LEFT JOIN
date functions
—191. Find Missing IDs in a Sequence
medium
gaps
GENERATE_SERIES
EXCEPT
—192. Find Consecutive Activity Streaks (Islands Problem)
medium
islands
window functions
LAG
—193. Deduplicate Orders Keeping the Latest Entry
medium
deduplication
ROW_NUMBER
CTE
—194. Top 2 Products Per Category by Revenue
medium
TOP N per group
ROW_NUMBER
CTE
—195. Each Sale as a Percentage of Total Revenue
medium
window functions
SUM OVER
percentage
—196. Count New Customers Acquired Each Month
medium
CTE
GROUP BY
MIN
—197. Revenue by Order Status Using CASE Inside SUM
medium
CASE WHEN
SUM
GROUP BY
—198. Full Department Salary Statistics in One Query
medium
GROUP BY
COUNT
SUM
—199. Show Each Employee with Their Manager's Name
medium
self join
LEFT JOIN
hierarchy
—200. Order Details with Customer and Product Names
medium
JOIN
three-table join
INNER JOIN
—201. Four-Table JOIN with Category Filter
medium
JOIN
four-table join
INNER JOIN
—202. Find Customers Who Have Never Placed an Order
medium
LEFT JOIN
NULL check
IS NULL
—203. All Product Color and Size Combinations Using CROSS JOIN
medium
CROSS JOIN
Cartesian product
SELECT
—204. Most Recent Order Per Customer Using LATERAL JOIN
medium
LATERAL
CROSS JOIN LATERAL
correlated subquery
—205. Weekly Sales Totals Using DATE_TRUNC
medium
DATE_TRUNC
GROUP BY
SUM
—206. Year-over-Year Revenue Growth Using LAG
medium
window functions
LAG
ORDER BY
—207. Month-over-Month Revenue Growth Rate
medium
window functions
LAG
ORDER BY
—208. User Cohort Retention by First Purchase Month
medium
cohort analysis
CTE
DATE_TRUNC
—209. Month-2 Retention Rate Calculation
medium
CTE
COUNT DISTINCT
LEFT JOIN
—210. Funnel Analysis with Step-by-Step Conversion Rates
medium
CTE
LAG
COUNT DISTINCT
—211. ABC Inventory Classification by Cumulative Revenue
medium
CTE
window functions
SUM OVER
—212. Customer Tier Segmentation Using NTILE
medium
window functions
NTILE
ORDER BY
—213. Revenue Concentration — Cumulative % Per Customer
medium
window functions
SUM OVER
cumulative
—214. Median Salary Per Department Using PERCENTILE_CONT
medium
PERCENTILE_CONT
WITHIN GROUP
ORDER BY
—215. Find the Most Frequently Occurring Rating (Mode)
medium
GROUP BY
COUNT
RANK
—216. Salary Spread by Department Using STDDEV_POP
medium
STDDEV_POP
GROUP BY
AVG
—217. Weighted Average Purchase Price Per Product
medium
GROUP BY
SUM
weighted average
—218. Rolling 7-Day Revenue Sum
medium
window functions
SUM OVER
ROWS BETWEEN
—219. Identify SLA Breaches Using DATEDIFF
medium
DATEDIFF
CASE WHEN
date arithmetic
—220. Pivot Monthly Revenue into Jan–Dec Columns
medium
PIVOT
CASE WHEN
GROUP BY
—221. Multi-Level Aggregation (Aggregate of Aggregates)
medium
SELECT
GROUP BY
subquery
—222. Scalar Subquery in SELECT Clause
medium
SELECT
correlated subquery
AVG
—223. Subquery in FROM Clause (Derived Table / Inline View)
medium
SELECT
subquery
FROM
—224. Multiple Window Functions in One Query
medium
SELECT
window functions
ROW_NUMBER
—225. Running Maximum with RANGE BETWEEN UNBOUNDED PRECEDING
medium
SELECT
window functions
MAX OVER
—226. Monthly Session Counts with Date-Based Partition
medium
SELECT
window functions
COUNT OVER
—227. Named Window Using the WINDOW Clause
medium
SELECT
window functions
WINDOW clause
—228. FILTER Clause with Aggregate Functions
medium
SELECT
FILTER
GROUP BY
—229. Conditional COUNT with CASE Expression
medium
SELECT
GROUP BY
COUNT
—230. Revenue Share per Category Using Window SUM
medium
SELECT
window functions
SUM OVER
—231. Compare Each Employee to Their Department Average Salary
medium
SELECT
window functions
AVG OVER
—232. Detect Price Changes Using LAG
medium
SELECT
window functions
LAG
—233. Days Until Next Event Using LEAD
medium
SELECT
window functions
LEAD
—234. Classify Employees into Salary Bands Using CASE
medium
SELECT
CASE
GROUP BY
—235. Employees in Top 10% by Salary Using PERCENT_RANK
medium
SELECT
window functions
PERCENT_RANK
—236. Ratio of Each Category to Total Revenue
medium
SELECT
GROUP BY
SUM
—237. Rank Products Within Each Brand by Price
medium
SELECT
window functions
RANK
—238. First and Last Purchase Date per Customer
medium
SELECT
GROUP BY
MIN
—239. Customers Who Never Made a Second Purchase
medium
SELECT
GROUP BY
HAVING
—240. Aggregate Orders by Weekday vs Weekend
medium
SELECT
EXTRACT
ISODOW
—241. Count Orders by Hour of Day
medium
SELECT
EXTRACT
HOUR
—242. Products with High Average Review Rating
medium
SELECT
JOIN
GROUP BY
—243. Customers Who Purchased from Every Category
medium
SELECT
JOIN
GROUP BY
—244. Email Domain Frequency Analysis
medium
SELECT
GROUP BY
COUNT
—245. Phone Number Format Validation with SIMILAR TO
medium
SELECT
SIMILAR TO
LIKE
—246. Longest Gap Between Consecutive Orders per Customer
medium
SELECT
window functions
LAG
—247. Days Since Last Order per Customer
medium
SELECT
GROUP BY
MAX
—248. New vs Returning Customers per Month
medium
SELECT
CTE
GROUP BY
—249. Repeat Purchase Rate Calculation
medium
SELECT
subquery
COUNT
—250. Customer Purchase Frequency Distribution
medium
SELECT
GROUP BY
COUNT
—251. RFM Analysis — Recency, Frequency, Monetary Buckets
medium
SELECT
CTE
window functions
—252. Product Co-Purchase Analysis
medium
SELECT
self join
GROUP BY
—253. Sales Velocity — Units Sold per Day per Product
medium
SELECT
GROUP BY
SUM
—254. Inventory Days Remaining Calculation
medium
SELECT
JOIN
ROUND
—255. Supplier Lead Time Analysis
medium
SELECT
GROUP BY
AVG
—256. Average Order Value by Acquisition Channel
medium
SELECT
GROUP BY
AVG
—257. Revenue per Employee by Department
medium
SELECT
JOIN
GROUP BY
—258. Budget vs Actual Spend Comparison
medium
SELECT
JOIN
COALESCE
—259. Join on Multiple Columns (Composite Key)
medium
SELECT
JOIN
composite key
—260. Finding Duplicate Records Across Columns
medium
SELECT
GROUP BY
HAVING
—261. Remove Duplicates Keeping the Most Recent Record
medium
SELECT
window functions
ROW_NUMBER
—262. Comparing Two Datasets with FULL OUTER JOIN
medium
SELECT
FULL OUTER JOIN
COALESCE
—263. Detecting Anomalies Using Z-Score Approach
medium
SELECT
CTE
JOIN
—264. Rolling 30-Day Distinct Customer Count
medium
SELECT
self join
GROUP BY
—265. Month-End Date Calculation
medium
SELECT
DATE_TRUNC
INTERVAL
—266. Assign Sales to Fiscal Year Quarters
medium
SELECT
CASE
EXTRACT
—267. Count Business Days Between Two Dates
medium
SELECT
generate_series
EXTRACT
—268. Calculate Age in Years from Birthdate
medium
SELECT
AGE
EXTRACT
—269. Timestamp to Date Conversion and Daily Grouping
medium
SELECT
DATE_TRUNC
CAST
—270. Detect Overlapping Date Ranges
medium
SELECT
self join
date ranges
—271. Assign Row Numbers Within Department Groups
medium
SELECT
window functions
ROW_NUMBER
—272. Split Comma-Separated Tags and Count Frequency
medium
SELECT
STRING_TO_ARRAY
UNNEST
—273. Aggregating JSON Array Element Counts
medium
SELECT
json_array_length
JSON
—274. Finding Maximum Streak of Consecutive Login Days
medium
SELECT
CTE
ROW_NUMBER
—275. Customer Segments by Spending Quartile
medium
SELECT
CTE
window functions
—276. Product Categories with Month-over-Month Revenue Decline
medium
SELECT
CTE
window functions
—277. Employees Promoted in the Last 6 Months
medium
SELECT
JOIN
WHERE
—278. Transactions More Than 3 Standard Deviations Above Mean
medium
SELECT
subquery
AVG
—279. Cumulative Sum That Resets on Partition Change
medium
SELECT
window functions
SUM OVER
—280. Multi-Step CTE Pipeline for Complex Analytics
medium
SELECT
CTE
JOIN
—281. Recursive Bill of Materials Explosion
hard
recursive CTE
self join
aggregation
—282. Full Org Chart Path as String
hard
recursive CTE
string concatenation
tree traversal
—283. Graph Shortest Path via BFS
hard
recursive CTE
graph traversal
BFS
—284. Fibonacci Sequence via Recursive CTE
hard
recursive CTE
sequence generation
BIGINT
—285. Sliding 30-Day Revenue Window per Customer
hard
window functions
RANGE BETWEEN
interval arithmetic
—286. Session Stitching with 30-Minute Gap Tolerance
hard
window functions
LAG
CTE
—287. Merge Overlapping Subscription Intervals
hard
window functions
CTE
islands and gaps
—288. Time-Series Gap Filling with Zero Revenue Days
hard
GENERATE_SERIES
LEFT JOIN
CROSS JOIN
—289. Monthly Sales Pivot Table (Jan–Dec)
hard
pivot
CASE
aggregation
—290. Quarterly Revenue Unpivot (Wide to Long Format)
hard
unpivot
UNION ALL
normalization
—291. Busiest 3 Consecutive Days by Revenue
hard
window functions
ROWS BETWEEN
LEAD
—292. Median Salary by Department using PERCENTILE_CONT
hard
PERCENTILE_CONT
ordered-set aggregate
window functions
—293. Fraud Detection: 3+ Transactions Within 1 Hour
hard
self join
CTE
timestamp arithmetic
—294. Customer Lifetime Value Projection
hard
CTE
aggregation
arithmetic
—295. Cohort Retention Analysis Pipeline
hard
CTE
DATE_TRUNC
AGE
—296. Nearest Price Match Across Two Catalogs
hard
CROSS JOIN
window functions
ROW_NUMBER
—297. Balanced Task Distribution with NTILE
hard
NTILE
window functions
CTE
—298. String Parsing: Extract Structured Data from Concatenated Field
hard
SPLIT_PART
string functions
data cleaning
—299. Weighted Composite Product Ranking
hard
window functions
CTE
normalization
—300. Maximum Concurrent Bookings per Room
hard
CTE
UNION ALL
window functions
—301. Compute Profit per Product
easy
SELECT
arithmetic
calculated column
—302. Count Orders by Status
easy
GROUP BY
COUNT
aggregate
—303. Find Employees in a Named Department
easy
JOIN
INNER JOIN
WHERE
—304. Products Below Reorder Level
easy
SELECT
WHERE
filtering
—305. Extract Day of Week from Order Date
easy
SELECT
EXTRACT
date functions
—306. Find Customers with No Phone Number
easy
SELECT
WHERE
IS NULL
—307. Calculate Salary After a 10% Bonus
easy
SELECT
arithmetic
calculated column
—308. Products Whose Name Starts with 'A'
easy
SELECT
WHERE
LIKE
—309. Total Revenue per Product
easy
GROUP BY
SUM
aggregate
—310. Filter Orders by a Specific Date
easy
SELECT
WHERE
date functions
—311. Sort Employees by Hire Date
easy
SELECT
ORDER BY
sorting
—312. Count Products per Category
easy
GROUP BY
COUNT
aggregate
—313. Find the Highest and Lowest Salary
easy
SELECT
MAX
MIN
—314. Customers with Long Names
easy
SELECT
WHERE
LENGTH
—315. Uppercase Product Names
easy
SELECT
string functions
UPPER
—316. Score Remainder with the Modulo Operator
easy
SELECT
arithmetic
MOD
—317. Calculate the Discount Amount per Product
easy
SELECT
arithmetic
calculated column
—318. Count Orders Grouped by Year and Month
easy
GROUP BY
COUNT
EXTRACT
—319. Orders in a Date Range (BETWEEN)
easy
SELECT
WHERE
BETWEEN
—320. Count NULL Values in a Column
easy
SELECT
COUNT
IS NULL
—321. Assign Letter Grades with CASE WHEN
easy
SELECT
CASE
CASE WHEN
—322. Fetch the First 3 Products Alphabetically (LIMIT)
easy
SELECT
ORDER BY
LIMIT
—323. Filter Employees by Status Using IN
easy
SELECT
WHERE
IN
—324. Format Order IDs with Zero-Padding
easy
SELECT
LPAD
string functions
—325. All Departments Including Those with No Employees
easy
RIGHT JOIN
JOIN
joins
—326. Generate All Month–Category Combinations
easy
CROSS JOIN
JOIN
joins
—327. Pick the First Non-NULL Name with COALESCE
easy
SELECT
COALESCE
NULL handling
—328. High-Volume, High-Value Customers (HAVING with AND)
easy
GROUP BY
HAVING
COUNT
—329. Customers Who Have Placed at Least One Order
easy
SELECT
EXISTS
subquery
—330. Combine Employees and Contractors with UNION
easy
UNION
SET operations
SELECT
—331. Customers With Strictly Increasing Order Values
medium
CTE
window functions
LAG
—332. Rank Products by Revenue Within Each Category
medium
CTE
window functions
RANK
—333. Monthly Active User Count
medium
DATE_TRUNC
COUNT DISTINCT
GROUP BY
—334. Churn Detection: Customers Inactive for 90+ Days
medium
CTE
subquery
date arithmetic
—335. Top-Selling Product in Each Region
medium
CTE
window functions
ROW_NUMBER
—336. Employee Salary Growth Over Time
medium
window functions
LAG
PARTITION BY
—337. Order Items With No Discount Applied
medium
LEFT JOIN
IS NULL
anti-join
—338. Total Revenue by Day of Week
medium
EXTRACT
GROUP BY
SUM
—339. Detect Same-Direction Price and Quantity Changes
medium
CTE
window functions
LAG
—340. Cumulative Order Count per Region
medium
window functions
SUM OVER
PARTITION BY
—341. Salary Percentile Rank Within Department
medium
window functions
PERCENT_RANK
PARTITION BY
—342. Customer Order Gap Alert (30–60 Days)
medium
CTE
date arithmetic
BETWEEN
—343. Products Ordered by Every Customer
medium
subquery
GROUP BY
HAVING
—344. Top Salesperson Each Quarter
medium
CTE
window functions
ROW_NUMBER
—345. Detect Overdue Invoices and Days Late
medium
CASE WHEN
date arithmetic
IS NULL
—346. Average Product Rating (Minimum 5 Reviews Required)
medium
GROUP BY
HAVING
AVG
—347. Product Price Range Histogram
medium
CASE WHEN
GROUP BY
COUNT
—348. Employee vs Manager Salary Gap
medium
self join
self-join
JOIN
—349. Revenue From First-Time vs Repeat Purchases
medium
CTE
window functions
ROW_NUMBER
—350. 7-Day Rolling Order Count
medium
window functions
SUM OVER
ROWS BETWEEN
—351. Most Popular Product Each Month
medium
CTE
window functions
ROW_NUMBER
—352. Customers Who Upgraded Their Loyalty Tier
medium
CTE
window functions
LAG
—353. Supplier Performance: Promised vs Actual Delivery Days
medium
JOIN
GROUP BY
AVG
—354. Category Market Share of Total Revenue
medium
CTE
window functions
SUM OVER
—355. Employees Sharing at Least One Project
medium
self join
self-join
GROUP BY
—356. Inventory Turnover Rate per Product
medium
SELECT
arithmetic
calculated column
—357. Calculate Net Promoter Score (NPS)
medium
FILTER
conditional aggregation
COUNT
—358. Orders Where Every Line Item Is Shipped
medium
GROUP BY
HAVING
FILTER
—359. Region × Quarter Revenue Pivot Matrix
medium
conditional aggregation
FILTER
EXTRACT
—360. Median Days Between Customer Purchases
medium
CTE
window functions
LAG
—361. Product Return Rate as Percentage
medium
GROUP BY
FILTER
conditional aggregation
—362. Monthly Revenue With Simple Growth Forecast
medium
window functions
LAG
analytics
—363. Employees Assigned to Multiple Departments
medium
GROUP BY
HAVING
COUNT DISTINCT
—364. High-Value Order Alert (2× Customer Average)
medium
CTE
subquery
JOIN
—365. Month-Over-Month Revenue Trend by Category
medium
window functions
LAG
PARTITION BY
—366. Time Between Order Status Transitions
medium
CTE
window functions
LAG
—367. Assign Customer Lifetime Value Tiers
medium
CTE
CASE WHEN
GROUP BY
—368. Product Co-Purchase Affinity Score
medium
self join
self-join
GROUP BY
—369. Manager Span of Control (Direct Reports Count)
medium
self join
self-join
GROUP BY
—370. Peak Order Hour per Day
medium
CTE
window functions
ROW_NUMBER
—371. Regional Sales Rep Performance with Rank
medium
CTE
window functions
RANK
—372. Detect Overstocked Products (3× Average Sales)
medium
SELECT
WHERE
arithmetic
—373. Win-Back: Customers Who Returned After 90-Day Dormancy
medium
CTE
window functions
LAG
—374. Invoice Aging Bucket Report
medium
CTE
CASE WHEN
GROUP BY
—375. Employee Headcount by Salary Band
medium
CASE WHEN
GROUP BY
COUNT
—376. Percentage of Orders With Multiple Products
medium
subquery
COUNT DISTINCT
CASE WHEN
—377. Average Basket Size per Customer
medium
JOIN
GROUP BY
COUNT DISTINCT
—378. Product Revenue Contribution via CTE
medium
CTE
percentage
arithmetic
—379. Weekly Signup Cohort Active Users
medium
CTE
DATE_TRUNC
date grouping
—380. Top 3 Categories by Order Count
medium
GROUP BY
COUNT
ORDER BY
—381. Maximum Non-Overlapping Meetings
hard
recursive CTE
ROW_NUMBER
CTE
—382. Three-Day Moving Median Revenue
hard
PERCENTILE_CONT
WITHIN GROUP
correlated subquery
—383. Required Skills Missing per Employee
hard
CTE
LEFT JOIN
anti-join
—384. Point-in-Time Price from SCD Type 2 History
hard
LEAD
window functions
PARTITION BY
—385. Two-Hop Follower Influence Score
hard
CTE
JOIN
aggregation
—386. Three-Period Loan Amortization
hard
recursive CTE
ROUND
arithmetic
—387. Four-Team Single-Elimination Bracket
hard
CTE
CASE WHEN
JOIN
—388. Org-Chart Budget Rollup
hard
recursive CTE
hierarchy
tree traversal
—389. First, Last, and Linear Touch Attribution
hard
window functions
ROW_NUMBER
COUNT OVER
—390. Weekly Cohort Retention Percentages
hard
CTE
DATE_TRUNC
COUNT DISTINCT
—391. Project Critical Path Length
hard
recursive CTE
MAX
JOIN
—392. Revenue-Maximizing Price per Product
hard
ROW_NUMBER
PARTITION BY
arithmetic
—393. Checkout Funnel Drop-Off Rates
hard
CTE
LAG
COUNT DISTINCT
—394. Collaborative Filtering Recommendations for User 1
hard
CTE
JOIN
aggregation
—395. Intraday Time-Weighted Average Price
hard
LEAD
window functions
weighted average
—396. Exponential Moving Average with Alpha 0.3
hard
recursive CTE
ROW_NUMBER
ROUND
—397. Nearest Neighbor by Euclidean Distance
hard
CROSS JOIN
ROW_NUMBER
SQRT
—398. Multi-Level Sales Commission
hard
subquery
CASE WHEN
arithmetic
—399. Portfolio Mean, Volatility, and 95% VaR
hard
JOIN
STDDEV_POP
AVG
—400. Monthly Revenue and New-Customer Dashboard
hard
CTE
DATE_TRUNC
LAG