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
ExperiencesCoaching
New
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
Get started
First 100 Days Visualization Comparison
00:00
5 left

First 100 Days Visualization Comparison

MediumSQL · PostgreSQL

Problem

How Product1 and Product2 performed for the first 100 days from their launch date. The result should be like Day1 Product1 Product2

Asked in the technical screen stage. This was the final and hardest of 5 SQL questions on Orders, Products, and Sellers tables.

Output

  1. Return exactly one row for each day number from 1 through 100.
  2. Columns: day_number, product1, and product2, showing units sold for each product on that relative launch day.
  3. Include days with no orders as zero, and order by day_number ascending.

Output details

  • Treat day 1 as each product's launch date, with each subsequent day advancing one calendar day.
  • Match orders only when order_date equals the calculated calendar date for that product and relative day.
  • Calculate each product's units as the sum of quantity, ignoring null quantities and returning 0 when no non-null quantity exists.
  • Return product1 and product2 totals as whole-number bigint values.

Schema

products
ColumnTypeDescription
product_idPKINTUnique product identifier
product_nameVARCHAR(100)Product display name
launch_dateDATEDate the product launched
categoryVARCHAR(100)Product category
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
product_idINTOrdered product identifier
order_dateDATEDate the order was placed
quantityINTNumber of units in the order
seller_nameVARCHAR(100)Seller associated with the order
Tablesproductsorders
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

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.