Learning areas/SQL Interview Prep

SQL Interview track

SQL Interview Prep

50 real SQL interview questions — Easy, Moderate and Hard — with ready answers you run and explain.

Learn in this order

Start at step 1. Each idea prepares you for the next one.

0/8
  1. 1Read and filter rows
  2. 2Sort, limit and summarise
  3. 3Group and filter groups
  4. 4Handle NULLs and conditions
  5. 5Join tables together
  6. 6Use subqueries and CTEs
  7. 7Rank with window functions
  8. 8Solve senior-level puzzles

Continue where you left off

Q1 · Easy: Return every row

50 questions remaining in this sector

Resume →
Industry context

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

0/15 done
15 questions left to earn this certificate
  1. Q1 · Easy: Return every row
  2. Q2 · Easy: Return two columns
  3. Q3 · Easy: Filter by text
  4. Q4 · Easy: Filter by number
  5. Q5 · Easy: Sort descending
  6. Q6 · Easy: Top 3
  7. Q7 · Easy: Count rows
  8. Q8 · Easy: Total
  9. Q9 · Easy: Average
  10. Q10 · Easy: Min and max
  11. Q11 · Easy: Unique categories
  12. Q12 · Easy: Rename a column
  13. Q13 · Easy: Two conditions
  14. Q14 · Easy: Either condition
  15. Q15 · Easy: In a list

Q1 · Easy: Return every row

+20 XP

You are a data analyst. Finance interview. Return all rows and columns.

SQLSELECT *SQL interview

Q2 · Easy: Return two columns

+20 XP

You are a data analyst. Finance interview. Return only the category and number columns.

SQLSELECTSQL interview

Q3 · Easy: Filter by text

+20 XP

You are a data analyst. Finance interview. Return rows for one category.

SQLWHERESQL interview

Q4 · Easy: Filter by number

+20 XP

You are a data analyst. Finance interview. Return rows where the number is above 5.

SQLWHERESQL interview

Q5 · Easy: Sort descending

+20 XP

You are a data analyst. Finance interview. Sort rows largest number first.

SQLORDER BYSQL interview

Q6 · Easy: Top 3

+20 XP

You are a data analyst. Finance interview. Return the top 3 rows by number.

SQLLIMITSQL interview

Q7 · Easy: Count rows

+20 XP

You are a data analyst. Finance interview. How many rows are in the table?

SQLCOUNTSQL interview

Q8 · Easy: Total

+20 XP

You are a data analyst. Finance interview. Return the total of the number column.

SQLSUMSQL interview

Q9 · Easy: Average

+20 XP

You are a data analyst. Finance interview. Return the average number.

SQLAVGSQL interview

Q10 · Easy: Min and max

+20 XP

You are a data analyst. Finance interview. Return the smallest and largest numbers.

SQLMIN/MAXSQL interview

Q11 · Easy: Unique categories

+20 XP

You are a data analyst. Finance interview. List each category once.

SQLDISTINCTSQL interview

Q12 · Easy: Rename a column

+20 XP

You are a data analyst. Finance interview. Return the number column renamed as value.

SQLASSQL interview

Q13 · Easy: Two conditions

+20 XP

You are a data analyst. Finance interview. Rows in one category AND number above 1.

SQLANDSQL interview

Q14 · Easy: Either condition

+20 XP

You are a data analyst. Finance interview. Rows where number is below 3 OR above 50.

SQLORSQL interview

Q15 · Easy: In a list

+20 XP

You are a data analyst. Finance interview. Rows whose category is in a list of two.

SQLINSQL interview

Beginner · SQL Interview & BETWEEN

2 exercises — finish them all to earn a certificate

0/2 done
2 questions left to earn this certificate
  1. Q16 · Easy: Range
  2. Q17 · Easy: Pattern match

Intermediate · SQL Interview & Data Aggregation

15 exercises — finish them all to earn a certificate

0/15 done
15 questions left to earn this certificate
  1. Q18 · Moderate: Count per group
  2. Q19 · Moderate: Sum per group
  3. Q20 · Moderate: Filter groups
  4. Q21 · Moderate: Sorted groups
  5. Q22 · Moderate: Label with CASE
  6. Q23 · Moderate: Conditional count
  7. Q24 · Moderate: Missing values
  8. Q25 · Moderate: Replace missing
  9. Q26 · Moderate: Above average
  10. Q27 · Moderate: Inner join
  11. Q28 · Moderate: Left join
  12. Q29 · Moderate: Rows without a match
  13. Q30 · Moderate: Find duplicates
  14. Q31 · Moderate: Combine results
  15. Q32 · Moderate: Exists check

Q18 · Moderate: Count per group

+20 XP

You are a data analyst. Finance interview. Count rows per category.

SQLGROUP BYSQL interview

Q19 · Moderate: Sum per group

+20 XP

You are a data analyst. Finance interview. Total number per category.

SQLGROUP BYSQL interview

Q20 · Moderate: Filter groups

+20 XP

You are a data analyst. Finance interview. Categories with more than 1 row.

SQLHAVINGSQL interview

Q21 · Moderate: Sorted groups

+20 XP

You are a data analyst. Finance interview. Category totals, largest first.

SQLGROUP BY + ORDER BYSQL interview

Q22 · Moderate: Label with CASE

+20 XP

You are a data analyst. Finance interview. Label each row High or Low.

SQLCASE WHENSQL interview

Q23 · Moderate: Conditional count

+20 XP

You are a data analyst. Finance interview. Count rows of the pick category without WHERE.

SQLCASE in SUMSQL interview

Q24 · Moderate: Missing values

+20 XP

You are a data analyst. Finance interview. Find rows where the number is missing.

SQLIS NULLSQL interview

Q25 · Moderate: Replace missing

+20 XP

You are a data analyst. Finance interview. Show 0 when the number is missing.

SQLCOALESCESQL interview

Q26 · Moderate: Above average

+20 XP

You are a data analyst. Finance interview. Rows with number above the average.

SQLSubquerySQL interview

Q27 · Moderate: Inner join

+20 XP

You are a data analyst. Finance interview. Join the table to a targets table on category.

SQLJOINSQL interview

Q28 · Moderate: Left join

+20 XP

You are a data analyst. Finance interview. Keep all rows even without a target.

SQLLEFT JOINSQL interview

Q29 · Moderate: Rows without a match

+20 XP

You are a data analyst. Finance interview. Rows that have no target.

SQLAnti-joinSQL interview

Q30 · Moderate: Find duplicates

+20 XP

You are a data analyst. Finance interview. Categories that appear more than once.

SQLDuplicatesSQL interview

Q31 · Moderate: Combine results

+20 XP

You are a data analyst. Finance interview. Stack the pick rows and big rows without repeats.

SQLUNIONSQL interview

Q32 · Moderate: Exists check

+20 XP

You are a data analyst. Finance interview. Rows whose category has a target.

SQLEXISTSSQL interview

Intermediate · SQL Interview & Ratios

2 exercises — finish them all to earn a certificate

0/2 done
2 questions left to earn this certificate
  1. Q33 · Moderate: Percentage of total
  2. Q34 · Moderate: Create a table

Advanced · SQL Interview & RANK()

15 exercises — finish them all to earn a certificate

0/15 done
15 questions left to earn this certificate
  1. Q35 · Hard: Rank rows
  2. Q36 · Hard: Rank within groups
  3. Q37 · Hard: Top row per group
  4. Q38 · Hard: Second highest
  5. Q39 · Hard: Running total
  6. Q40 · Hard: Previous row
  7. Q41 · Hard: Moving average
  8. Q42 · Hard: Group avg beside rows
  9. Q43 · Hard: Multiple CTEs
  10. Q44 · Hard: Remove duplicates
  11. Q45 · Hard: Self join
  12. Q46 · Hard: Pivot
  13. Q47 · Hard: Percentile buckets
  14. Q48 · Hard: Upsert
  15. Q49 · Hard: Speed with an index

Q35 · Hard: Rank rows

+20 XP

You are a data analyst. Finance interview. Rank rows by number, biggest first.

SQLRANK()SQL interview

Q36 · Hard: Rank within groups

+20 XP

You are a data analyst. Finance interview. Rank rows inside each category.

SQLPARTITION BYSQL interview

Q37 · Hard: Top row per group

+20 XP

You are a data analyst. Finance interview. Largest row in each category.

SQLWindow + CTESQL interview

Q38 · Hard: Second highest

+20 XP

You are a data analyst. Finance interview. Return the second highest number.

SQLDENSE_RANKSQL interview

Q39 · Hard: Running total

+20 XP

You are a data analyst. Finance interview. Cumulative total ordered by id.

SQLSUM OVERSQL interview

Q40 · Hard: Previous row

+20 XP

You are a data analyst. Finance interview. Show each row's previous number and the change.

SQLLAGSQL interview

Q41 · Hard: Moving average

+20 XP

You are a data analyst. Finance interview. 3-row moving average.

SQLWindow frameSQL interview

Q42 · Hard: Group avg beside rows

+20 XP

You are a data analyst. Finance interview. Show each row next to its category average.

SQLAVG OVERSQL interview

Q43 · Hard: Multiple CTEs

+20 XP

You are a data analyst. Finance interview. Use two CTEs to find categories above the overall average.

SQLCTESQL interview

Q44 · Hard: Remove duplicates

+20 XP

You are a data analyst. Finance interview. Delete duplicate categories, keeping the first id.

SQLDELETE + windowSQL interview

Q45 · Hard: Self join

+20 XP

You are a data analyst. Finance interview. Pairs of rows in the same category.

SQLSelf joinSQL interview

Q46 · Hard: Pivot

+20 XP

You are a data analyst. Finance interview. One column per category total.

SQLPivotSQL interview

Q47 · Hard: Percentile buckets

+20 XP

You are a data analyst. Finance interview. Split rows into 2 buckets by number.

SQLNTILESQL interview

Q48 · Hard: Upsert

+20 XP

You are a data analyst. Finance interview. Insert a row or update it if the id exists.

SQLON CONFLICTSQL interview

Q49 · Hard: Speed with an index

+20 XP

You are a data analyst. Finance interview. Create an index to speed up category filters.

SQLIndexesSQL interview

Advanced · Gaps & Islands & SQL Interview

1 exercises — finish them all to earn a certificate

0/1 done
1 question left to earn this certificate
  1. Q50 · Hard: Gaps and islands