Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Join Customer Tickets and Error Logs

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

Your question is Join Customer Tickets and Error Logs. 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

You are given customer, ticket, and error-log data for an Aveva support workflow. Write a PostgreSQL query that joins the three tables to help troubleshoot a recurring issue by returning each customer’s open or recently closed tickets with the matching error details, including a flag that marks whether the error appears more than once for that customer.

Use the data to surface only tickets tied to the recurring error pattern and order the result so the most recent ticket appears first.

Schema

customers
ColumnTypeDescription
customer_idPKINTPrimary key for the customer
customer_nameVARCHAR(100)Customer display name
account_tierVARCHAR(50)Support tier or contract level
tickets
ColumnTypeDescription
ticket_idPKINTPrimary key for the ticket
customer_idINTReferences customers.customer_id
opened_atTIMESTAMPTimestamp when the ticket was opened
closed_atTIMESTAMPTimestamp when the ticket was closed
statusVARCHAR(30)Ticket status
issue_codeVARCHAR(50)Issue code reported on the ticket
error_logs
ColumnTypeDescription
error_idPKINTPrimary key for the error event
customer_idINTReferences customers.customer_id
occurred_atTIMESTAMPTimestamp when the error occurred
error_codeVARCHAR(50)Machine-readable error code
error_messageTEXTHuman-readable error message
Tablescustomersticketserror_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results