Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Users Did A But Not B

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

Your question is Users Did A But Not B. Start with the requirements and the two 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

Networth wants to identify users who viewed the Networth dashboard but did not connect a bank account during the same seven-day reporting period. Write a PostgreSQL query for the reporting period ending 2025-02-16.

For this task, action A is viewed_dashboard and action B is connected_bank_account.

Requirements

  1. Consider events from 2025-02-10 through 2025-02-16, inclusive.
  2. Return users who performed action A at least once and action B zero times during that period.
  3. Include users with no events only when they do not qualify, and return user_id and email ordered by user_id.

Schema

users
ColumnTypeDescription
user_idPKINTEGERUnique Networth user identifier
emailVARCHAR(255)User email address
signup_dateDATEDate the user registered
user_actions
ColumnTypeDescription
action_idPKINTEGERUnique action event identifier
user_idINTEGERReferences users.user_id
action_nameVARCHAR(50)Name of the action performed
occurred_atTIMESTAMPTimestamp when the action occurred
Tablesusersuser_actions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results