Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Using SQL for Complex Problems
00:00
5 left

Using SQL for Complex Problems

HardSQL · PostgreSQL

Problem

Describe a time when you used SQL to solve a complex data problem.

For this exercise, use the provided Docker organization, membership, and activity-event tables. Write a query that identifies organizations with at least two active members and two activity events during January 2025.

Output

  1. One row per qualifying organization
  2. Columns: organization_name, active_members, total_events, successful_events, failed_events, failure_rate_pct, and top_event_type
  3. Include the most frequent event type, breaking ties alphabetically
  4. Order by failure rate descending, then organization name ascending

Schema

organizations
ColumnTypeDescription
organization_idPKINTUnique organization identifier
organization_nameVARCHAR(100)Docker organization name
organization_members
ColumnTypeDescription
membership_idPKINTUnique membership record identifier
organization_idINTOrganization associated with the membership
member_idINTMember identifier
membership_statusVARCHAR(20)Current membership status
activity_events
ColumnTypeDescription
event_idPKINTUnique activity event identifier
organization_idINTOrganization associated with the event
member_idINTMember responsible for the event, when available
event_typeVARCHAR(30)Type of activity recorded
outcomeVARCHAR(20)Event outcome
event_timestampTIMESTAMPTimestamp when the event occurred
Tablesorganizationsorganization_membersactivity_events
Interviewer

Your question is Using SQL for Complex Problems. Start with the requirements and the three 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.