近期在準備北美資料崗位,陸續參與多家大廠的資料相關面試,涵蓋 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。