Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2013-08-21 : 03:19:34
|
Hi, I got a table with Transaction of Debit and Credit Amount. Need a Output for Current Outstanding Amount for Past 30 days Debited Data. TableA:[ID] [DATE] [DEBIT] [CREDIT] [NAME] 1 2013-06-01 500 - A 2 2013-06-15 750 - B 1 2013-06-30 - 400 A 2 2013-07-01 - 750 B 3 2013-07-20 200 - C 4 2013-07-25 500 - D 5 2013-07-30 300 - E 4 2013-08-01 - 300 D 3 2013-08-10 - 200 C 6 2013-08-15 400 - F 6 2013-08-15 - 300 F From the Above Table Current Outstanding Will be SUM(DEBIT)-SUM(CREDIT) -- 2650-1950=700But I need the Outstanding Pending Amount for Past Months Data which was not Credited. OUTPUT: (Current Month Transaction of Debit will not Considered but have to Consider the Credit Amount For Past Transaction)[ID] [DATE] [DEBIT] [CREDIT] [NAME] 1 2013-06-01 500 - A 2 2013-06-15 750 - B 1 2013-06-30 - 400 A 2 2013-07-01 - 750 B 3 2013-07-20 200 - C 4 2013-07-25 500 - D 5 2013-07-30 300 - E 4 2013-08-01 - 300 D 3 2013-08-10 - 200 CNow the SUM(DEBIT)-SUM(CREDIT) -- 2250-1650=600.Please help me to fix with Query...Regards,Kalai |
|
VeeranjaneyuluAnnapureddy
Posting Yak Master
169 Posts |
Posted - 2013-09-03 : 08:19:26
|
SELECT Value = (SUM(DEBIT) - SUM(CREDIT) )FROM TABLESELECT Value = (SUM(DEBIT) - SUM(CREDIT) )FROM TABLE1veeranjaneyulu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-09-03 : 09:36:45
|
can you explain how you managed exclude last two rows? you've previous two rows also coming for same month but you took that into consideration.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|