TranID Date AccNum Type Amount ChequeNo DDNo 657520 02-07-1999 0181432 Debit 16000 465774 657524 02-07-1999 0181432 Debit 13000 569086 657538 09-07-1999 0181432 Credit 11000 657548 18-07-1999 0181432 Credit 15500 657519 02-07-1999 0181432 Debit 12000 657523 02-07-1999 0181432 Credit 11000 657529 03-07-1999 0181432 Debit 15000 466777 657539 10-07-1999 0181432 Credit 10000 657541 11-07-1999 0181432 Debit 12000 657525 03-07-1999 0181432 Debit 15000 569999 657533 05-07-1999 0181432 Credit 12500 #### #!/usr/bin/perl use DBI; use strict; use warnings; $dbh = DBI->connect('dbi:database','prithvi','prithvi') or die "Couldn't connect"; my $tran_cur = $dbh->prepare("SELECT AccountNumber, Type, SUM(Amount) FROM transaction GROUP BY AccountNumber, Type;"); $tran_cur->execute; print ""; map {print ""}qw(Account Number-Total Debit Amount); print "
"; print ""; print "
$_
"; while( my @data = $tran_cur->fetchrow_array) { my $rec = join ('-',@data); print "$rec\n"; } $dbh->disconnect; ##
## 1) Query data from transaction table and calculate the total balance in each account 2) Query data from transaction table and calculate total amount debited by cheque, dd and by cash for each account.