MEDIUMVerified Real Interview• Product Analytics Analyst

Weekend vs. Weekday Engagement Split

Meta's Instagram engagement team wants to compare user posts published on Weekends (Saturday, Sunday) versus Weekdays (Monday - Friday).

Write a SQL query using CASE WHEN and PostgreSQL EXTRACT(ISODOW FROM ...) or TO_CHAR to calculate:

  • user_id
  • weekday_posts (count of posts created Monday through Friday)
  • weekend_posts (count of posts created Saturday or Sunday)
  • pct_weekend_posts (percentage of total posts on weekends, rounded to 1 decimal place)

Only include users who published at least 3 total posts. Order by pct_weekend_posts descending.

Tables:

  • posts (post_id INT, user_id INT, post_timestamp TIMESTAMP)

Execution Sandbox:

Your query executes inside an isolated in-memory PostgreSQL engine (PGlite WebAssembly). You have full access to standard PostgreSQL aggregations, window functions, and CTEs.

Standard SQL (ANSI)|Ln 1, Col 1
⌘↵ Run Query
Ready to execute. Press Run (⌘+Enter)
Write your query and click “Run” or press ⌘+Enter to inspect output.