http://www.perlmonks.org?node_id=997539


in reply to Re^5: SQL Database Table to Perl Script
in thread SQL Database Table to Perl Script

1) Query data from transaction table and calculate the total balance in each account

Select columns from your table, group by "accnum". When "type" = 'credit', then add "amount"; when "type" = 'debit', subtract "amount". And then display the result as a column in your resultset.

2) Query data from transaction table

SELECT columns FROM transaction table

and calculate total amount

sum(...)

debited by cheque,

chequeno IS NOT NULL

dd

ddno IS NOT NULL

and by cash

chequeno IS NULL AND ddno IS NULL

for each account.

GROUP BY accnum

For the rest, why not look here? And there.