近期在准备北美数据岗位,陆续参与多家大厂的数据相关面试,涵盖 DA / DS 等方向。本次 Meta 的 SQL 面试在整体结构和考察方式上具有较强代表性:统一业务背景、连续多题追问。相比单纯考察 SQL 语法熟练度,这一轮更侧重对业务抽象能力和数据分析思路的评估。
面试概览
- 公司:Meta
- 岗位:数据相关岗位(偏 DA / DS)
- 形式:线上视频面试
- 语言:中文
- 时长:约 35 分钟
- 内容:
- SQL 多题连问
- 统一业务场景(Shop Visibility)
- 后半段偏指标设计 + SQL 实现
Meta SQL 经典真题分享
Question1: Users with Many Searches
题目难度:easy
Count the number of users who made more than 5 searches in August 2021.
表结构:fb_searches
| 字段名 | 类型 |
|---|---|
| age_group | text |
| date | date |
| search_id | bigint |
| search_query | text |
| user_id | bigint |
解题思路
sql
SELECT count(user_id) AS result
FROM
(SELECT user_id,
count(search_id) AS august_searches
FROM fb_searches
WHERE date BETWEEN '2021-08-01' AND '2021-08-31'
GROUP BY user_id) a
WHERE august_searches > 5
Question2: Number of Conversations
题目难度:Medium
Count the total number of distinct conversations on WhatsApp. Two users share a conversation if there is at least 1 message between them.
Multiple messages between the same pair of users are considered a single conversation.
表结构:whatsapp_messages
| 字段名 | 类型 |
|---|---|
| message_date | date |
| message_id | bigint |
| message_receiver_id | text |
| message_sender_id | text |
| message_time | text |
解题思路
WITH all_conversation_combinations AS
(SELECT message_sender_id AS user1,
message_receiver_id AS user2
FROM whatsapp_messages
UNION SELECT message_receiver_id AS user1,
message_sender_id AS user2
FROM whatsapp_messages)
SELECT COUNT(*) AS number_of_conversations
FROM all_conversation_combinations
WHERE user1 < user2
Question3:
题目难度:Hard
Meta/Facebook’s web logs capture every action from users starting from page loading to page scrolling.
Find the user with the least amount of time between a page load and their scroll down.
Your output should include the user id, page load time, scroll down time, and time between the two events in seconds.
表结构:facebook_web_log
| 字段名 | 类型 |
|---|---|
| action | text |
| timestamp | timestamp without time zone |
| user_id | bigint |
解题思路
WITH cte AS
(SELECT user_id,
load_time,
scroll_time,
duration::TIME AS duration
FROM
(SELECT t1.user_id,
t1.timestamp AS load_time,
t2.timestamp AS scroll_time,
t2.timestamp - t1.timestamp duration
FROM facebook_web_log t1
JOIN facebook_web_log t2 ON t1.user_id = t2.user_id
WHERE t1.action = 'page_load'
AND t2.action = 'scroll_down'
AND t2.timestamp > t1.timestamp )sq
),
rank_cte AS
(SELECT *,
rank() OVER (ORDER BY duration) AS rnk
FROM cte)
SELECT user_id,
load_time,
scroll_time,
duration
FROM rank_cte
WHERE rnk = 1
为什么这轮我会提前找 Programhelp
其实在准备 Meta 这轮之前,我已经明显感觉到一个变化: 北美大厂的数据岗 / SQL 面试,越来越像“实时博弈”,而不是静态刷题。 很多问题本身不难,但会被不断追问、不断收紧条件,如果当下思路一旦走偏,很容易在面试里直接迷路。这种情况下,单靠 AI 或事后复盘,帮助其实非常有限。 也是在这个阶段,我接触到了 Programhelp 的 面试辅助 ,最后成功拿到offer。