Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Common Users Between Two Tables

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

Your question is Common Users Between Two Tables. 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

Paytm wants to identify users who used both Paytm Wallet and Paytm UPI during January 2026. Write a PostgreSQL query that returns the common user_id values from the two activity tables.

Requirements

  1. Consider only activity from 2026-01-01 through 2026-01-31, inclusive.
  2. Return each user only once, even if the user has multiple activity records in either table.
  3. Exclude rows where user_id is NULL.
  4. Sort the result by user_id in ascending order.

Schema

wallet_activity
ColumnTypeDescription
event_idPKINTUnique Paytm Wallet activity event
user_idINTPaytm user identifier
activity_dateDATEDate of Wallet activity
upi_activity
ColumnTypeDescription
event_idPKINTUnique Paytm UPI activity event
user_idINTPaytm user identifier
activity_dateDATEDate of UPI activity
Tableswallet_activityupi_activity
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results