Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: SQL Database Table to Perl Script

by prithviraj (Novice)
on Oct 05, 2012 at 17:23 UTC ( #997523=note: print w/replies, xml ) Need Help??


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

Sir.For the question below, I want to solve it with a single SQL query. I tried all possibilities but nothing is working. Please help: Query data from transaction table and calculate total amount debited by cheque, dd and by cash for each account.
  • Comment on Re^5: SQL Database Table to Perl Script

Replies are listed 'Best First'.
Re^6: SQL Database Table to Perl Script
by Anonymous Monk on Oct 05, 2012 at 20:13 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997523]
help
Chatterbox?
[hippo]: That was around April 1994. Fun times.
[hippo]: They had purchased some shiny new 486 DXs the year before but crippled them by installing Win 3.1. I demo'd Linux with X on them to the department head and got the go-ahead to wipe Windows and install the new hotness.
[marto]: glory days ;)

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2018-06-22 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (124 votes). Check out past polls.

    Notices?