LISTING 2: Query That Returns Transaction Details and Amount Positions SELECT account_id, tran_id, amount, (SELECT COUNT(*) FROM Trans1 AS T1B WHERE T1B.account_id = T1.account_id AND T1B.amount = T1.amount AND T1B.tran_id <= T1.tran_id) AS position FROM Trans1 AS T1 ORDER BY account_id, amount, tran_id