AXISHK
asked on
Sum up a field in SQL Statement
I have a table like this
account, year, period, amount
491 2008 1 100
491 2008 1 50
491 2008 1 -100
491 2008 1 -200
Result
account year period DrAmt CrAmt
491 2008 1 150 -300
The amount is either +ve or -ve value. Is it possible to write a single SQL statement to display a summary of +ve value and -ve value in two separate calculation field ?
thank
account, year, period, amount
491 2008 1 100
491 2008 1 50
491 2008 1 -100
491 2008 1 -200
Result
account year period DrAmt CrAmt
491 2008 1 150 -300
The amount is either +ve or -ve value. Is it possible to write a single SQL statement to display a summary of +ve value and -ve value in two separate calculation field ?
thank
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
group by account
--group by might not be needed, if you get errors, try just
select sum(amount) as Total from <table name>