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
Sum Quantity by Inventory Type
00:00
5 left

Sum Quantity by Inventory Type

EasySQL · PostgreSQL

Problem

A Guidewire Cloud Data Platform support team maintains store inventory used for implementation and customer enablement activities. Write a PostgreSQL query that reports the total available quantity for every inventory type.

Requirements

  1. Return every row from inventory_types, including types with no active items.
  2. Sum quantity only for store_items whose status is active.
  3. Treat missing or NULL quantities as zero and return zero when a type has no active inventory.
  4. Sort the results alphabetically by inventory type name.

Schema

inventory_types
ColumnTypeDescription
inventory_type_idPKINTEGERPrimary key for an inventory type
inventory_type_nameVARCHAR(80)Display name of the inventory type
store_items
ColumnTypeDescription
item_idPKINTEGERPrimary key for an inventory item
inventory_type_idINTEGERReferences inventory_types.inventory_type_id
item_nameVARCHAR(120)Name of the stored item
quantityINTEGERCurrent quantity of the item
statusVARCHAR(20)Current item state
Tablesinventory_typesstore_items
Interviewer

Your question is Sum Quantity by Inventory Type. 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.