Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL for Daily Segmented Pageviews
00:00
5 left

SQL for Daily Segmented Pageviews

MediumSQL · PostgreSQL

Problem

Write a query to calculate the total pageviews and unique visitors for a specific feature on LinkedIn, grouped by day and user segment. Use Jobs as the feature and treat each matching event row as one pageview. Include only events with a matching user record, including users whose segment is NULL.

Output

  1. One row per day and user segment
  2. Columns: viewed_day, user_segment, total_pageviews, and unique_visitors
  3. Sort by viewed_day ascending, then user_segment ascending with NULL segments last

Schema

feature_pageviews
ColumnTypeDescription
pageview_idPKINTUnique identifier for the pageview event
viewed_atTIMESTAMPTimestamp when the feature pageview occurred
feature_nameVARCHAR(100)LinkedIn feature viewed by the visitor
visitor_idVARCHAR(50)Identifier for the visitor
user_idINTLinkedIn user associated with the event
linkedin_users
ColumnTypeDescription
user_idPKINTUnique LinkedIn user identifier
user_segmentVARCHAR(50)Analytical segment assigned to the user
Tablesfeature_pageviewslinkedin_users
Interviewer

Your question is SQL for Daily Segmented Pageviews. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.