How to study SQL for FREE
Marketer's Edition - Special contribution to LeetCode and Notion
When I first started learning SQL, it was more like because of the essence of urgent business needs, when bosses asked for the number but had to stop waiting for days until an analyst to pull out raw data. If you’ve worked in marketing, you know how often questions like these come up:
Which products performed best during last month’s campaign?
How many users were active in the past 30 days?
Who signed up but never purchased?
In many cases, SQL is used in the backend to extract the number from the data pool. And the good news is: you don’t need to pay hefty cost for a fancy course or a bootcamp. You can practice for free on LeetCode (they do have subscription model as well).
When I was intensively studying SQL, I was still employed full-time hence I can only afford to spend 15 to 20 minutes every day to solve each question. Among the questions I solved, I picked eight that could be useful for marketers. Most of the questions here are labelled as Easy to Medium, but I found the essence of query is good enough for marketers. These exercises are completely free and resemble the real data challenges you’ll face in your office.
(Disclaimer - free questions may change to subscription only, all depends on LeetCode’s decision. As of July 2025, these are all open for free.)
For each problem, I’ll share 1) What it teaches 2) My mistakes and 3) Marketing angle.
1. List the Products Ordered in a Period
Teaches: WHERE, GROUP BY, COUNT(), date filtering
Marketing angle: Think about seasonal campaigns. Maybe you want to know which products sold during your Summer Promotion, then this query is the basic angle that you can try.
2. User Activity for the Past 30 Days I
Teaches: DATE_SUB(), filtering by date, grouping
My mistake: I tried to use ORDER BY DESC then LIMIT 30, but made some mistakes in the order of query sequences.
Marketing angle: This logic can be applied to DAU (Daily Active Users) analysis. If you work on apps or websites, you can try this question.
3. Tree Node
Teaches: CASE WHEN, self-joins, hierarchy
My mistake: This questions looks tricky but very simple if you get the logic. I tried to solve this using only Self-Join, but CASE WHEN will make things much easier.
Marketing angle: If you manage multi-level campaigns (Brand → Product Line → Ads), understanding relationships like root vs leaf matters a lot.
4. Replace Employee ID With The Unique Identifier
Teaches: JOIN, handling missing matches
Marketing angle: This is like mapping customer IDs to ad platforms or products. The query is useful when you’re trying to integrate data sources.
5. Department Top Three Salaries
Teaches: DENSE_RANK(), PARTITION BY
My mistake: Tried using LIMIT 3 but realized it returns the result of top 3 overall, not per department. Moreover, read the question carefully to decide whether to use RANK() or DENSE_RANK().
Marketing angle: Ranking campaigns by revenue to evaluate the ROAS of ads.
6. Customers Who Never Order
Teaches: LEFT JOIN, IS NULL
Marketing angle: Easy but useful question to practice writing queries for retargeting campaigns. Who are the returning customers? Who are we missing after sign-ups?
7. Human Traffic of Stadium
Teaches: Multiple times of self-join. Or you can try using ROW_NUMBER()
My mistake: Self-join concept straightforward but make sure to find the right start of the column when you are extracting it from SELECT. You may end up extracting the wrong column after nicely writing whole chunk of multiple self-join lines.
Marketing angle: Spotting traffic peaks on your website, great to identify when is the peak time of campaign.
8. Project Employees I
Teaches: AVG(), GROUP BY
Why it matters: Simple but useful without writing long query. By using AVG() you can decide the average spend of campaign so that resource allocation can be done more efficiently.
Final Thoughts
SQL is a tool to bridge data scientists and marketers. Although not all companies are allowing marketers to use SQL, still it gives you an idea about how to dissemble the problem into chunks and how we should start analyzing it. Questions here could be easy if you already have some understanding about SQL query writing, so you can challenge yourself by solving more open questions on LeetCode.
Moreover, I suggest you create a tracker to visually show your progress and note down your own insights and mistakes. I personally used Notion to track the links of the questions I solved, review status, mistakes and marketing insights.
In terms of business point, these problems taught me the patterns I now use for:
Campaign performance analysis
CRM segmentation
Retention and churn analysis
Just 15 minutes a day, then you’ll find yourself getting more confidence in writing SQL queries!

