FastPrepInactive Customers with Prior Activity

Inactive Customers with Prior Activity

Mastercard logoMastercard● MediumFULLTIMEPHONE SCREEN

Problem statement

Find customers who made at least one transaction before the one-year lookback window but made no transaction during that window.

The window begins one calendar year before as_of_date, inclusive, and ends at as_of_date, exclusive. Customers who never transacted do not qualify.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

customers

ColumnTypeNullableDescription
customer_idPKIntegerNo—
customer_nameTextNo—

transactions

ColumnTypeNullableDescription
transaction_idPKIntegerNo—
customer_idIntegerNo—
transaction_dateDateNo—
transaction_amountDecimalNo—

Foreign key: customer_id → customers(customer_id)

analysis_params

Contains exactly one row with param_id 1.

ColumnTypeNullableDescription
param_idPKIntegerNo—
as_of_dateDateNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
customer_idIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • analysis_params contains exactly one row with param_id = 1.
  • Future-dated transactions do not count as prior or recent activity.
  • Return customer IDs ascending.

More Mastercard problems

See Mastercard hiring insights