Average Post Hiatus | Facebook SQL Interview Question
Given a table of Facebook posts, for each user who posted at least twice in 2021, write a query to find the number of days between each user’s first post of the year and last post of the year in the year 2021. Output the user and number of the days between each user's first and last post. p.s. If you've read the Ace the Data Science Interview and liked it, consider writing us a review? The dataset you are querying against may have different input & output - this is just an example! First, we can use the MIN() and MAX() aggregate functions on the post_date column to retrieve the earliest and latest post dates, and substract one from another accordingly. To calculate the difference for each user, we GROUP the results by user_id, and then filter for posts made in the year 2021. To do so, we use the DATE_PART() function to extract the year from the post_date column. In the final step, to exclude users who have posted only once during the year, we apply the HAVING clause with a COUNT() cond
Average Post Hiatus | Facebook SQL Interview Question Share Premium Back to questions Average Post Hiatus (Part 1) Facebook SQL Interview Question Average Post Hiatus (Part 1) Facebook SQL Interview Question Question Solution Discussion Submissions Given a table of Facebook posts, for each user who posted at least twice in 2021, write a query to find the number of days between each user’s first post of the year and last post of the year in the year 2021. Output the user and number of the days between each user's first and last post. p.s. If you've read the Ace the Data Science Interview and li
saved by
related reading
- Day Of The Week Analysis in SQL - Issue 39dataanalysis.substack.com
- database design - Calendar Recurring/Repeating Events - Best Storage Method - Stack Overflowstackoverflow.com
- An Overview of Distributed PostgreSQL... | Crunchy Data Blogcrunchydata.com
- Best time to post on social media in 2025 (by platform)blog.hootsuite.com
- A More Human Approach To Databasesccorcos.github.io
- Incremental Database Computationsfeldera.com
- you won't forget how postgres works after thisyoutube.com
- Materialized views are obviously useful – Sophie Alpertsophiebits.com
- Databases are Fucking Stupid | Probably Danceprobablydance.com
- pthorpe92.devpthorpe92.dev
- HyperLogLog: A Simple but Powerful Algorithm for Data Scientists | Towards Data Sciencetowardsdatascience.com
- Monitor with pg_stat_statements | Databricks on AWSdocs.databricks.com