SQL Interview track
SQL Interview Prep
50 real SQL interview questions — Easy, Moderate and Hard — with ready answers you run and explain.
Start at step 1. Each idea prepares you for the next one.
- 1Read and filter rows
- 2Sort, limit and summarise
- 3Group and filter groups
- 4Handle NULLs and conditions
- 5Join tables together
- 6Use subqueries and CTEs
- 7Rank with window functions
- 8Solve senior-level puzzles
Continue where you left off
Q1 · Easy: Return every row
50 questions remaining in this sector
Your datasets, exercises and portfolio outputs stay inside the sector you choose.
Beginner · SQL Interview & Data Filtering
15 exercises — finish them all to earn a certificate
15 questions left to earn this certificate
- Q1 · Easy: Return every row
- Q2 · Easy: Return two columns
- Q3 · Easy: Filter by text
- Q4 · Easy: Filter by number
- Q5 · Easy: Sort descending
- Q6 · Easy: Top 3
- Q7 · Easy: Count rows
- Q8 · Easy: Total
- Q9 · Easy: Average
- Q10 · Easy: Min and max
- Q11 · Easy: Unique categories
- Q12 · Easy: Rename a column
- Q13 · Easy: Two conditions
- Q14 · Easy: Either condition
- Q15 · Easy: In a list
Q1 · Easy: Return every row
+20 XPYou are a data analyst. Finance interview. Return all rows and columns.
Q2 · Easy: Return two columns
+20 XPYou are a data analyst. Finance interview. Return only the category and number columns.
Q3 · Easy: Filter by text
+20 XPYou are a data analyst. Finance interview. Return rows for one category.
Q4 · Easy: Filter by number
+20 XPYou are a data analyst. Finance interview. Return rows where the number is above 5.
Q5 · Easy: Sort descending
+20 XPYou are a data analyst. Finance interview. Sort rows largest number first.
Q6 · Easy: Top 3
+20 XPYou are a data analyst. Finance interview. Return the top 3 rows by number.
Q7 · Easy: Count rows
+20 XPYou are a data analyst. Finance interview. How many rows are in the table?
Q8 · Easy: Total
+20 XPYou are a data analyst. Finance interview. Return the total of the number column.
Q9 · Easy: Average
+20 XPYou are a data analyst. Finance interview. Return the average number.
Q10 · Easy: Min and max
+20 XPYou are a data analyst. Finance interview. Return the smallest and largest numbers.
Q11 · Easy: Unique categories
+20 XPYou are a data analyst. Finance interview. List each category once.
Q12 · Easy: Rename a column
+20 XPYou are a data analyst. Finance interview. Return the number column renamed as value.
Q13 · Easy: Two conditions
+20 XPYou are a data analyst. Finance interview. Rows in one category AND number above 1.
Q14 · Easy: Either condition
+20 XPYou are a data analyst. Finance interview. Rows where number is below 3 OR above 50.
Q15 · Easy: In a list
+20 XPYou are a data analyst. Finance interview. Rows whose category is in a list of two.
Beginner · SQL Interview & BETWEEN
2 exercises — finish them all to earn a certificate
2 questions left to earn this certificate
Intermediate · SQL Interview & Data Aggregation
15 exercises — finish them all to earn a certificate
15 questions left to earn this certificate
- Q18 · Moderate: Count per group
- Q19 · Moderate: Sum per group
- Q20 · Moderate: Filter groups
- Q21 · Moderate: Sorted groups
- Q22 · Moderate: Label with CASE
- Q23 · Moderate: Conditional count
- Q24 · Moderate: Missing values
- Q25 · Moderate: Replace missing
- Q26 · Moderate: Above average
- Q27 · Moderate: Inner join
- Q28 · Moderate: Left join
- Q29 · Moderate: Rows without a match
- Q30 · Moderate: Find duplicates
- Q31 · Moderate: Combine results
- Q32 · Moderate: Exists check
Q18 · Moderate: Count per group
+20 XPYou are a data analyst. Finance interview. Count rows per category.
Q19 · Moderate: Sum per group
+20 XPYou are a data analyst. Finance interview. Total number per category.
Q20 · Moderate: Filter groups
+20 XPYou are a data analyst. Finance interview. Categories with more than 1 row.
Q21 · Moderate: Sorted groups
+20 XPYou are a data analyst. Finance interview. Category totals, largest first.
Q22 · Moderate: Label with CASE
+20 XPYou are a data analyst. Finance interview. Label each row High or Low.
Q23 · Moderate: Conditional count
+20 XPYou are a data analyst. Finance interview. Count rows of the pick category without WHERE.
Q24 · Moderate: Missing values
+20 XPYou are a data analyst. Finance interview. Find rows where the number is missing.
Q25 · Moderate: Replace missing
+20 XPYou are a data analyst. Finance interview. Show 0 when the number is missing.
Q26 · Moderate: Above average
+20 XPYou are a data analyst. Finance interview. Rows with number above the average.
Q27 · Moderate: Inner join
+20 XPYou are a data analyst. Finance interview. Join the table to a targets table on category.
Q28 · Moderate: Left join
+20 XPYou are a data analyst. Finance interview. Keep all rows even without a target.
Q29 · Moderate: Rows without a match
+20 XPYou are a data analyst. Finance interview. Rows that have no target.
Q30 · Moderate: Find duplicates
+20 XPYou are a data analyst. Finance interview. Categories that appear more than once.
Q31 · Moderate: Combine results
+20 XPYou are a data analyst. Finance interview. Stack the pick rows and big rows without repeats.
Q32 · Moderate: Exists check
+20 XPYou are a data analyst. Finance interview. Rows whose category has a target.
Intermediate · SQL Interview & Ratios
2 exercises — finish them all to earn a certificate
2 questions left to earn this certificate
Advanced · SQL Interview & RANK()
15 exercises — finish them all to earn a certificate
15 questions left to earn this certificate
- Q35 · Hard: Rank rows
- Q36 · Hard: Rank within groups
- Q37 · Hard: Top row per group
- Q38 · Hard: Second highest
- Q39 · Hard: Running total
- Q40 · Hard: Previous row
- Q41 · Hard: Moving average
- Q42 · Hard: Group avg beside rows
- Q43 · Hard: Multiple CTEs
- Q44 · Hard: Remove duplicates
- Q45 · Hard: Self join
- Q46 · Hard: Pivot
- Q47 · Hard: Percentile buckets
- Q48 · Hard: Upsert
- Q49 · Hard: Speed with an index
Q35 · Hard: Rank rows
+20 XPYou are a data analyst. Finance interview. Rank rows by number, biggest first.
Q36 · Hard: Rank within groups
+20 XPYou are a data analyst. Finance interview. Rank rows inside each category.
Q37 · Hard: Top row per group
+20 XPYou are a data analyst. Finance interview. Largest row in each category.
Q38 · Hard: Second highest
+20 XPYou are a data analyst. Finance interview. Return the second highest number.
Q39 · Hard: Running total
+20 XPYou are a data analyst. Finance interview. Cumulative total ordered by id.
Q40 · Hard: Previous row
+20 XPYou are a data analyst. Finance interview. Show each row's previous number and the change.
Q41 · Hard: Moving average
+20 XPYou are a data analyst. Finance interview. 3-row moving average.
Q42 · Hard: Group avg beside rows
+20 XPYou are a data analyst. Finance interview. Show each row next to its category average.
Q43 · Hard: Multiple CTEs
+20 XPYou are a data analyst. Finance interview. Use two CTEs to find categories above the overall average.
Q44 · Hard: Remove duplicates
+20 XPYou are a data analyst. Finance interview. Delete duplicate categories, keeping the first id.
Q45 · Hard: Self join
+20 XPYou are a data analyst. Finance interview. Pairs of rows in the same category.
Q46 · Hard: Pivot
+20 XPYou are a data analyst. Finance interview. One column per category total.
Q47 · Hard: Percentile buckets
+20 XPYou are a data analyst. Finance interview. Split rows into 2 buckets by number.
Q48 · Hard: Upsert
+20 XPYou are a data analyst. Finance interview. Insert a row or update it if the id exists.
Q49 · Hard: Speed with an index
+20 XPYou are a data analyst. Finance interview. Create an index to speed up category filters.
Advanced · Gaps & Islands & SQL Interview
1 exercises — finish them all to earn a certificate