
PUZZLE 38 JOURNAL UPDATING 155
PUZZLE
38 JOURNAL UPDATING
This is a simple accounting puzzle. You are given a table that represents
an accounting journal with transaction dates, transaction amounts, and
the accounts to which they are applied. You are to find the number of
days between each transaction and post that number of days on the first
of the transactions, effectively giving you how many days until the next
transaction against that account.
Assume that the table is very simple:
CREATE TABLE Journal
(acct_nbr INTEGER NOT NULL,
trx_date DATE NOT NULL,
trx_amt DECIMAL (10, 2) NOT NULL,
duration INTEGER NOT NULL);
Answer #1
The first answer ...