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
Aggregate Sales With Time Zones
00:00
5 left

Aggregate Sales With Time Zones

MediumSQL · PostgreSQL

Problem

Write a query to aggregate sales data while handling time-zone complexities at Wayfair.

Use the provided sales and fulfillment-center data. Include completed sales with non-null amounts and convert each sale to the local calendar date of its fulfillment center.

Output

  1. One row per fulfillment center and local sale date.
  2. Columns: center_name, local_sale_date, order_count, and gross_sales.
  3. Exclude sales without a matching fulfillment center, a valid time zone, or a qualifying amount and status.
  4. Order by local_sale_date, then center_name.

Schema

sales_orders
ColumnTypeDescription
order_idPKINTUnique sales order identifier
center_idINTFulfillment center associated with the sale
occurred_atTIMESTAMPTZSale timestamp stored with its absolute time-zone offset
statusVARCHAR(20)Current order status
sale_amountNUMERIC(10,2)Gross amount for the sale
fulfillment_centers
ColumnTypeDescription
center_idPKINTUnique fulfillment center identifier
center_nameVARCHAR(100)Fulfillment center name
time_zoneVARCHAR(64)IANA time-zone name for the center
Tablessales_ordersfulfillment_centers
Interviewer

Your question is Aggregate Sales With Time Zones. 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.