A True Story
In my second year as a data product manager at Baidu, the business team urgently needed a user retention data report, but the data analysts were all busy with another major project that week. After waiting two days with no results, I opened the SQL editor myself, spent 20 minutes writing a query, and pulled the data out.
That was the first time I truly felt it: PMs who know SQL and PMs who don't are practically two different species in terms of work efficiency.
Later, when I interviewed many PM candidates, I noticed a pattern: candidates who could write their own SQL queries had noticeably deeper business understanding. Because they weren't just looking at pre-packaged data reports — they were exploring the database themselves, discovering things that reports couldn't show.
So, should product managers learn SQL? My answer is: it's not "should" — it's "must."
Why PMs Must Learn SQL
1. Break Free from Dependency on Data Analysts
Data analyst resources at big tech companies are always scarce. One analyst might support 3-5 PMs simultaneously, and it's normal for your data request to be queued until next week. If you know SQL, simple data queries can be done in 10 minutes without waiting for anyone.
2. Interview Hard Requirement
In 2026, PM interviews at ByteDance, Meituan, Kuaishou, Pinduoduo, and similar companies almost always include SQL. They won't ask you to write extremely complex queries, but you should at least be able to write basic aggregate queries and multi-table joins on the spot.
3. Improve Data Sensitivity
When you query the database yourself, you develop a deeper understanding of table structures, field meanings, and data quality. This understanding feeds back into your product design capabilities — you'll have a clearer picture of what data can be collected, what metrics can be calculated, and what analyses can be performed.
4. Better Communication with Engineers
Understanding SQL means you understand basic database logic, so you won't be completely lost when discussing technical solutions with engineers. This is especially important in B2B product and data product scenarios.
SQL Basic Syntax: What PMs Must Master
SELECT: Querying Data
-- Query all users' names and registration times from the users table
SELECT user_name, register_time
FROM users
WHERE register_time >= '2026-01-01'
ORDER BY register_time DESC
LIMIT 100;This is the most basic query statement. SELECT chooses the fields to query, FROM specifies the table name, WHERE sets filter conditions, ORDER BY sorts, and LIMIT restricts the number of returned rows.
WHERE: Conditional Filtering
-- Query active users (logged in within the last 7 days)
SELECT user_id, user_name, last_login_time
FROM users
WHERE last_login_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)
AND status = 'active';The WHERE clause supports various conditions: =, >, <, >=, <=, !=, BETWEEN, IN, LIKE, IS NULL, etc. Multiple conditions are connected with AND or OR.
JOIN: Multi-Table Associations
-- Query users' order information
SELECT u.user_name, o.order_id, o.order_amount, o.create_time
FROM users u
LEFT JOIN orders o ON u.user_id = o.user_id
WHERE o.create_time >= '2026-01-01';JOIN is a critical concept PMs must master. In real business scenarios, data is scattered across different tables, and you need JOIN to connect them.
LEFT JOIN: Keeps all records from the left table, shows NULL for unmatched right table records (most commonly used)INNER JOIN: Only keeps records that match in both tablesRIGHT JOIN: Keeps all records from the right table (rarely used)
PMs most commonly use LEFT JOIN because you typically want to keep all users, even those without order records.
GROUP BY: Grouping and Aggregation
-- Count registered users and paying users by channel
SELECT channel,
COUNT(*) AS total_users,
SUM(CASE WHEN is_paid = 1 THEN 1 ELSE 0 END) AS paid_users,
ROUND(SUM(CASE WHEN is_paid = 1 THEN 1 ELSE
GROUP BY is the core of data analysis. Combined with aggregate functions like COUNT, SUM, AVG, MAX, and MIN, you can perform statistical analysis across various dimensions.
HAVING: Filtering Aggregated Results
-- Find cities with monthly active users exceeding 1000
SELECT city, COUNT(DISTINCT user_id) AS mau
FROM user_login_log
WHERE login_time >= '2026-03-01' AND login_time < '2026-04-01'
GROUP BY city
HAVING COUNT(DISTINCT user_id) > 1000
ORDER BY mau DESC;The difference between HAVING and WHERE: WHERE filters before grouping, HAVING filters after grouping. Use HAVING when you need to set conditions on aggregated results.
Business Scenario SQL: High-Frequency Interview Questions
Scenario 1: Calculating Next-Day Retention Rate
-- Calculate daily next-day retention rate for March 2026
SELECT a.login_date,
COUNT(DISTINCT a.user_id) AS day_users,
COUNT(DISTINCT b.user_id) AS retained_users,
ROUND(COUNT(DISTINCT b.user_id) * 100.
Retention rate is the most frequently asked SQL question in PM interviews. The core approach is using self-joins to connect the same user's login records across different dates.
Scenario 2: Funnel Analysis
-- E-commerce purchase funnel: View -> Add to Cart -> Order -> Pay
SELECT
COUNT(DISTINCT CASE WHEN event = 'view' THEN user_id END) AS view_users,
COUNT(DISTINCT CASE WHEN event = 'add_cart' THEN user_id END) AS cart_users,
COUNT(DISTINCT CASE WHEN
Funnel analysis SQL is relatively straightforward — the core is using CASE WHEN to count different events separately. In interviews, follow-up questions might include: How do you calculate conversion rates at each step? How do you break down the funnel by channel?
Scenario 3: User Segmentation (RFM Model)
-- Segment users based on recency and monetary value
SELECT user_id,
DATEDIFF(CURDATE(), MAX(order_time)) AS recency_days,
COUNT(*) AS frequency,
SUM(order_amount) AS monetary,
CASE
WHEN DATEDIFF(CURDATE(), MAX(order_time)) <= 30 AND SUM(order_amount) >= 1000 THEN
The RFM model is a classic user operations analysis framework that frequently appears in interviews. The core is using CASE WHEN to classify users based on thresholds across different dimensions.
Interview SQL Question Types Summary
| Question Type | Core Knowledge | Difficulty |
|---|---|---|
| Next-Day/7-Day Retention | Self-join, DATE functions | ⭐⭐⭐ |
| Funnel Conversion Analysis | CASE WHEN, COUNT DISTINCT | ⭐⭐ |
| User Segmentation/RFM | GROUP BY, CASE WHEN | ⭐⭐⭐ |
| Consecutive N-Day Login | Window functions, date diff | ⭐⭐⭐⭐ |
| Top N Problems | ROW_NUMBER window function | ⭐⭐⭐ |
| YoY/MoM Calculations | LAG window function | ⭐⭐⭐ |
| Distinct Counting | COUNT DISTINCT, subqueries | ⭐⭐ |
Window Functions: Interview Bonus Points
Window functions are advanced SQL content, but they appear increasingly frequently in interviews. PMs should know at least two:
ROW_NUMBER: Ranking
-- Top 3 products by sales in each category
SELECT *
FROM (
SELECT product_name, category, sales_amount,
ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales_amount DESC) AS rn
FROM products
) t
WHERE rn <= 3;LAG/LEAD: Year-over-Year and Month-over-Month
-- Calculate monthly GMV month-over-month growth rate
SELECT month,
gmv,
LAG(gmv) OVER (ORDER BY month) AS last_month_gmv,
ROUND((gmv - LAG(gmv) OVER (ORDER BY month)) * 100.0 / LAG(gmv) OVER (ORDER BY month),
Recommended Learning Resources
Beginner Stage (1-2 weeks)
- W3Schools SQL Tutorial: The most concise SQL beginner tutorial with an online practice environment
- SQLZoo: Interactive SQL practice platform — learn while you practice
- Nowcoder SQL Practice: One of the best SQL practice platforms with questions closely aligned to big tech interviews
Intermediate Stage (2-4 weeks)
- LeetCode SQL Problems: Practice by difficulty — Easy first, then Medium
- "SQL in 10 Minutes" by Ben Forta: A classic introductory book, thin enough to finish in a week
- Real Business Practice: Find a public dataset (like Kaggle) and simulate business scenarios with queries
Continuous Improvement
- Proactively use SQL to pull data at work — look up unfamiliar syntax as you go
- Follow data analysts' technical blogs to learn their query approaches
- Use ChatGPT / Cursor to assist learning — describe business requirements to AI, review the generated SQL, and understand each line
Common Misconceptions
Misconception 1: PMs Need to Master SQL
No. PMs need "sufficient" SQL ability — being able to independently handle 80% of daily data queries is enough. Complex data modeling and performance optimization are the data engineer's job.
Misconception 2: You Need to Learn Database Theory First
No. PMs learning SQL is like learning to drive — you don't need to understand engine mechanics, just know how to operate. Start directly with SELECT statements and fill in knowledge gaps as you encounter problems.
Misconception 3: Python Can Replace SQL
It can't. Python and SQL have different use cases. SQL is a language for directly querying databases; Python is better suited for data cleaning and complex analysis. For PMs, SQL's priority is far higher than Python's.
Summary
For product managers, SQL isn't a "nice-to-have" — it's a fundamental skill. It doesn't require a long time to learn — concentrate for two weeks, practice 1-2 hours daily, and you'll master the SQL skills needed for interviews and daily work.
Remember this: PMs who can pull their own data will always be more competitive than PMs who wait for others to provide it.