Bond Holders Above the Cash Flow Threshold
Problem statement
For each bond holder, add the cash flow from every bond they own. A bond contributes annual_coupon * coupons_remaining.
Return the holder’s name and total_cash_flow only when the combined, unrounded total is strictly greater than 10000.00. Round each returned total 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.
BondHolders
| Column | Type | Nullable | Description |
|---|---|---|---|
| idPK | Integer | No | — |
| name | Text | No | — |
Bonds
| Column | Type | Nullable | Description |
|---|---|---|---|
| idPK | Integer | No | — |
| name | Text | No | — |
| annual_coupon | Decimal | No | — |
| coupons_remaining | Integer | No | — |
BondHoldersBonds
| Column | Type | Nullable | Description |
|---|---|---|---|
| bond_idPK | Integer | No | — |
| bond_holder_idPK | Integer | No | — |
Foreign key: bond_id → Bonds(id)
Foreign key: bond_holder_id → BondHolders(id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| name | Text | No | — |
| total_cash_flow | Decimal | No | — |
Row order: any order is accepted. Numeric tolerance: 0.
Constraints
- The reported tables and columns are BondHolders(id, name), Bonds(id, name, annual_coupon, coupons_remaining), and BondHoldersBonds(bond_id, bond_holder_id).
- IDs are positive integers. Each holder-bond pair is unique and references existing rows. Names need not be unique; group holders by ID. All values are non-null.
- For practice, annual_coupon is a nonnegative exact decimal no greater than 1000000000 with at most four decimal places. coupons_remaining is an integer from 0 to 1000000.
- Compare the full exact sum before rounding. Round halfway values away from zero. A holder with no holdings has total zero and is excluded.
- Each table has at most 2000 rows. Output rows may be in any order.