FastPrepCredit and Debit Transaction Counts per User

Credit and Debit Transaction Counts per User

Mastercard logoMastercard● EasyFULLTIMEPHONE SCREEN

Problem statement

For every user appearing in the transaction table, count Credit and Debit transactions separately.

Return user_id, credit_count, and debit_count, including zero for a missing type.

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—
user_idIntegerNo—
transaction_typeTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
user_idIntegerNo—
credit_countIntegerNo—
debit_countIntegerNo—

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

Constraints

  • transaction_type is exactly Credit or Debit.
  • Each transaction counts once.
  • Sort users by ID ascending.

More Mastercard problems

See Mastercard hiring insights