Problem · Database

Transaction Balance Over Threshold

MediumIMC logoIMCFULLTIMEOA

Problem statement

You are given two tables, LOGIN and TRANSACT.

LOGIN

  • ACCOUNT CHAR(16)
  • USERNAME CHAR(20)
  • FIRST_NAME CHAR(20)
  • LAST_NAME CHAR(30)

TRANSACT

  • ACCOUNT CHAR(16)
  • AMOUNT INT
  • TIMESTAMP DATE

TRANSACT contains every change made to an account. Credits are positive, debits are negative, and every account starts with a balance of 0.

Return exactly one column, USERNAME, containing every username whose account has a net balance strictly greater than 10000. Compute an account's net balance as the sum of all of its TRANSACT.AMOUNT values.

The output row order is not significant.

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.

LOGIN

Login identity records from the source schema.

ColumnTypeNullableDescription
ACCOUNTTextNoAccount identifier; the source declares CHAR(16).
USERNAMETextNoUsername; the source declares CHAR(20).
FIRST_NAMETextNoFirst name; the source declares CHAR(20).
LAST_NAMETextNoLast name; the source declares CHAR(30).

TRANSACT

Account credits and debits from the source schema.

ColumnTypeNullableDescription
ACCOUNTTextNoAccount identifier; the source declares CHAR(16).
AMOUNTIntegerNoSigned balance change; credits are positive and debits are negative.
TIMESTAMPDateNoTransaction date; the source declares DATE.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
USERNAMETextNoUsername of an account whose balance exceeds 10000.

Row order: any order is accepted. Numeric tolerance: 0.

Constraints

  • For this practice version, every input cell is non-null.
  • LOGIN.ACCOUNT identifies at most one login row. An account may have any number of TRANSACT rows.
  • Text values respect the source-declared CHAR lengths.
  • AMOUNT is a signed integer: positive values are credits and negative values are debits.
  • TIMESTAMP is represented as an ISO date in YYYY-MM-DD form and does not affect the result.
  • Either table may be empty. An account with no transactions has balance 0, and transactions without a matching LOGIN row contribute no username.

Source note: Original assessment screenshot showing the source table schema and prompt.

More IMC problems