Introduction

I recently completed all 117 questions of SQL in 25 days on Leetcode which is probably one of the most popular websites to practice your coding skills in various programming languages. The website beautifully categorizes all the questions in three categories namely Easy, Medium, and Hard where the level of difficulty handsomely rises with each subsequent level. After completing all of them, I decided to highlight 10 questions which covers almost all the concepts ranging from Basic to Advanced SQL that you can practice in order to brush up your SQL programming skills. Additionally, all of these questions have been asked in interviews from almost all the big tech companies.

The following is the breakdown of SQL skills tested in every question:

  • **Q1 Average Salary: CTE, **Aggregates in Window functions, CASE WHEN, Date functions such as DATE_PART, INNER JOIN
  • **Q2 Find Quiet students in results— **Subqueries, MIN, MAX, Window functions, Window Alias, INNER JOIN, ALL keyword
  • **Q3 Human Traffic of Stadium — **LEFT JOIN with Subqueries, CTE, ROW_NUMBER
  • **Q4 Number of Transactions per Visit —**RECURSIVE CTE, COALESCE, COUNT
  • **Q5 Report contiguous dates (MySQL)— **Date_sub, ROW_NUMBER
  • **Q6 Sales by Day of the week — **Pivot table, CASE WHEN
  • **Q7 Department Top 3 Salaries— **DENSE_RANK
  • **Q8 Restaurant Growth — **PRECEDING for moving average, OFFSET
  • **Q9 Shortest distance in a Plane — **CROSS JOIN, SQRT, POW
  • **Q10 Consecutive Numbers —**LAG, LEAD

So, let’s get to the business!

#programming #interview #data-analysis #sql #data-science #data analysis

10 problems to practice almost all SQL concepts
3.45 GEEK