August 5, 2009 at 12:28 pm
Howdy Folks,
I'm trying to write a script that will only show the money that hasn't been accounted for. I have a table that has both + and - dollar figures in 1 table and over time they cancel each other out.
Any ideas on how to write the script to not show the cancelled out items?
i.e.
Ref# DetAmount
1234 -4000.00
1234 4000.00
1234 -6000.00
When I run the SELECT I just want to see the -6000.00
TIA
Wayne
Thank You Gah for the heads up. I hope this is better.
August 5, 2009 at 12:55 pm
Howdy Wayne
without any more info its really hard to provide an answer
but maybe that GROUP BY and SUM (use BOL) will assist
you may find that if you follow the advice in the link below that you get faster and more detailed response...paritcularly if you provide example of what you expect the results to be.....
http://www.sqlservercentral.com/articles/Best+Practices/61537/
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
August 6, 2009 at 8:01 am
Thank You Gah for the heads up. I hope this is better.
suggest you dont reply by editing original post...it will get missed.
try this
SELECT Ref#, SUM(DetAmount) AS Balance
FROM "yourtable"
GROUP BY Ref#
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply