Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Simple SQL Count Query

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Simple SQL Count Query. Start with the requirements and the three tables on the right.

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.

Problem

IBM Support wants a product-level view of support demand across IBM watsonx and related offerings. Write a PostgreSQL query that counts qualifying support tickets for every product, including products with no qualifying tickets.

Requirements

  1. Return every product and the number of support tickets created during Q1 2025, from January 1 through March 31.
  2. Count only tickets associated with accounts whose account_tier is Enterprise.
  3. Include products with zero qualifying tickets and order results by ticket count descending, then product name ascending.

Representative Sample Data

Schema

ibm_products
ColumnTypeDescription
product_idPKINTIBM product identifier
product_nameVARCHAR(100)IBM product name
support_accounts
ColumnTypeDescription
account_idPKINTCustomer account identifier
account_nameVARCHAR(100)Customer account name
account_tierVARCHAR(30)Customer account classification
support_tickets
ColumnTypeDescription
ticket_idPKINTSupport ticket identifier
product_idINTReferenced IBM product
account_idINTReferenced support account
created_atDATETicket creation date
statusVARCHAR(30)Current ticket status
priorityVARCHAR(20)Ticket priority
Tablesibm_productssupport_accountssupport_tickets
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results