FastPrepMerchant Category Transaction Summary

Merchant Category Transaction Summary

Mastercard logoMastercard● MediumFULLTIMEPHONE SCREEN

Problem statement

Summarize credit-card transactions by merchant category.

Return each category's average transaction amount rounded to two decimal places and its total transaction amount. Order categories by total amount descending, then category ascending.

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—
merchant_categoryTextNo—
transaction_amountDecimalNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
merchant_categoryTextNo—
average_transaction_amountDecimalNo—
total_transaction_amountDecimalNo—

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

Constraints

  • Every transaction has one merchant category and amount.
  • Category labels in a case are distinct under ordinary database text comparison.
  • Round only the displayed average; keep exact totals.

More Mastercard problems

See Mastercard hiring insights