ROW_NUMBER() OVER(PARTITION BY user_id ORDER BY event_time)
Find first/last event;
LAG() / LEAD()
Session gap, churn detection;
SUM(x) OVER(ORDER BY date)
Cumulative metrics;
DENSE_RANK()
Ranking with ties (e.g. top product categories);
COUNT(DISTINCT …)
Unique users, sessions;
Nested CASE WHEN
Conditional metrics;
“for each,” “per,” “every”
GROUP BY or PARTITION BY
“total,” “count,” “average,” “sum”
Aggregate functions (COUNT(), AVG(), etc.)
“most recent,” “latest,” “top 3,” “best”
ROW_NUMBER() or RANK() (Window Function)
“and see their…” (e.g., posts and see their reactions)
LEFT JOIN
“that also have” (e.g., posts that also have ‘heart’ reactions)
INNER JOIN or WHERE EXISTS
“users with more than 10 posts” (filtering on an aggregate)
HAVING clause