FastPrepYear-over-Year Transaction Growth by Region

Year-over-Year Transaction Growth by Region

Mastercard logoMastercard● MediumFULLTIMEPHONE SCREEN

Problem statement

For the region named in analysis_params, aggregate total transaction amount by calendar year and calculate year-over-year growth.

The first observed year, a year without the immediately preceding calendar year, or a year whose preceding total is zero must return NULL growth. Otherwise round the percentage to two decimal places.

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.

transactions

ColumnTypeNullableDescription
transaction_idPKIntegerNo—
regionTextNo—
transaction_dateDateNo—
transaction_amountDecimalNo—

analysis_params

Contains exactly one target region row with param_id 1.

ColumnTypeNullableDescription
param_idPKIntegerNo—
regionTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
transaction_yearIntegerNo—
total_transaction_amountDecimalNo—
yoy_growth_percentDecimalYes—

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

Constraints

  • analysis_params contains exactly one row with param_id = 1.
  • Use calendar years from transaction_date.
  • Sort by year ascending.

More Mastercard problems

See Mastercard hiring insights