Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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 and Python Coding Mix
00:00
5 left

SQL and Python Coding Mix

MediumSQL · PostgreSQL

Problem

Solve two SQL questions and one Python question based on the provided data.

Use the supplied users, posts, and comments tables. The SQL answers should identify active users from January 2025 and select the highest-scoring post in each subreddit. Provide the Python answer separately using the requested input and output format.

Output

  1. SQL question 1: one row per qualifying user, with username, post_count, and average_score, ordered by average_score descending and username ascending.
  2. SQL question 2: one row per subreddit, with subreddit, post_id, title, score, and comment_count, ordered by subreddit ascending.
  3. Python: return the requested output shape for the supplied data.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
usernameVARCHAR(100)Display username
created_atTIMESTAMPUser creation timestamp
posts
ColumnTypeDescription
post_idPKINTUnique post identifier
user_idINTAuthor user identifier
subredditVARCHAR(100)Community containing the post
titleVARCHAR(255)Post title
scoreINTNet post score
created_atTIMESTAMPPost creation timestamp
comments
ColumnTypeDescription
comment_idPKINTUnique comment identifier
post_idINTPost receiving the comment
bodyTEXTComment text
created_atTIMESTAMPComment creation timestamp
Tablesuserspostscomments
Interviewer

Your question is SQL and Python Coding Mix. Start with the requirements and the three 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.