RienSQL
TASK #219 · Medium · BBVA

Account Statement: Cards and Transfers

Your brief
An account statement combines into one list the card payments from card_payments and the transfers from transfers in which the account is the sending or the receiving one.

Write a query that returns the statement of account 104 for May 2025. For each operation return:
• op_date — the operation date without the time;
• op_type — 'tarjeta' for a card payment, 'transferencia' for a transfer;
• concept — the merchant for a card payment, the concept for a transfer;
• amount — the signed amount: negative when money leaves account 104 (card payments and sent transfers), positive when it comes in.

Every operation is a separate row, even if two rows are identical. Sort the result by op_date and, within a date, by amount in ascending order.
Expected columnsop_date op_type concept amountBBVA
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
customerscustomer_id, full_name, city, joined_date
accountsaccount_id, customer_id, product, opened_date, start_balance
card_paymentspayment_id, account_id, paid_at, merchant, category, amount
transferstransfer_id, from_account_id, to_account_id, transfer_at, amount, concept