How to build query to give daily balance across bank accounts? (to then plot in a graph)

How would one build a query to give daily balance across bank accounts? (to then plot in a graph)
Assumptions:
* There is a table TRANSACTIONS which includes columns TRANS_DATE, AMOUNT and BANK_ID. It does NOT include a column for balance. So current balance for a bank account is the sum of the AMOUNTs for that BANK_ID for example. Balance on date XX will be the sum
of all AMOUNTS for that BANK_ID for all TRANS_DATE's prior and including the date XX.
* There is not necessarily transactions on every day for each bank
* Table BANKS which has BANK_ID and TITLE
Would like a query that gives: Supply StartDate and EndDate for the query:
Date Bank1Balance Bank2Balance Bank3Balance TotalBalance
1/1/15 $100 $200 $100 $400
1/2/15 $200 $200 $100 $500
etc

You'll find examples of queries for computing balances in various contexts in Balances.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
The queries in this little demo file return balances per transaction, however, whereas you appear to wish to return balances at close of business per day.  This can easily be done by means of a subquery which sums all transactions to date.  To return
balances for all dates regardless of whether or not any transactions have been undertaken on the day, an auxiliary calendar table can be introduced into the database to plug the gaps,  The Calendar.zip file in my same OneDrive folder has means of generating
such a table.
With the introduction of an auxiliary calendar table into the database a query can then be written to return the balance per customer at close of business per day over the period 2009 - 2012 covered by the data in the Transactions table:
SELECT CustomerID, Firstname, LastName, calDate,
   (SELECT SUM(TransactionAmount)
     FROM Transactions
     WHERE Transactions.CustomerID = Customers.CustomerID
     AND Transactions.TransactionDate <= Calendar.calDate) AS Balance
FROM Calendar,Customers
WHERE calDate BETWEEN #2009-01-01# AND #2012-12-31#
ORDER BY CustomerID, CalDate;
Rows for each customer/date are returned by means of the Cartesian product of the Calendar and Customers tables (the latter analogous to your Banks table), and the subquery returns the balance at close of each day by correlating the Transactions table with
the Customers and Calendar tables, returning the sum of all transactions per customer up to and including the date in question.  In this example credit and debit transactions are expressed as positive and negative values in a single column of course,
but where separate credit and debit columns are used its merely a case of summing (Credit-Debit), as done in some of the examples in my demo.
To return the data in a horizontal format per date I'd suggest the use of a report which returns one row per date, and within it a multi-column subreport in across-then down column layout, linking the subreport to the parent report on the date columns.
Ken Sheridan, Stafford, England

Similar Messages

  • How can i remove an unwanted store balance from my account

    how can i remove an unwanted store balance from my account

    If you can't spend it then you can try contacting iTunes support and ask if they can remove the balance from ir for you : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page.

  • F110 & actual balance in bank account

    Hi All,
    When we do payment run, system automatically take house bank & bank account configured in FBZP based on payment method given in F110.
    But if anyhow amount does not actaully exist in that bank account, payment will not go to vendor.
    So how it is practially checked the amount availability & which bank account to be used for payment.
    Please suggest.
    Regards
    Deepak

    Hi Deepak,
    The house bank is determined as a combination of company code and payment method entered in the parameters of F110 payment run.
    In FBZP, we maintain the available amount for each bank account. There is no way to determine the actual amount physically available in the bank account.
    The only check that will take place within SAP is that the payment being made meets the Available amount requirement set in FBZP.
    Hope this helps
    Regards
    PG

  • App store police regarding free downloads and 0 balance in bank account

    What is the app store police regarding free downloads and 0 balance in bank account.

    You must have a credit or debit card account on file to download free or purchased apps. Apple verifies your account credentials with every download.

  • How to get the GL Daily Balances for an Account

    Hi,
    We need to create a report to see the daily balances (as at date) from 11i GL.
    Our accounting periods are defined as calender months.
    Ex: Account Combination X.XXX.XXXX.XXX Balance as at 11-AUG-09
    Please let us know the tables which we need to query for this requirement.
    Thanks!

    Hello Nilaksha.
    You can use the following query. Modify the segment to be queried if you wish.
    SELECT cc.segment1||'.'||segment2||'.'||segment3||'.'||segment4 "Account",
    nvl(sum(l.accounted_dr - l.accounted_cr),0) "Balance"
    FROM gl_code_combinations cc,
    gl_je_lines l
    WHERE cc.code_combination_id = l.code_combination_id
    AND l.set_of_books_id = <your set_of_books_id'
    AND cc.segment2 = 'your segment value'
    AND l.effective_date <= '30-nov-09'
    GROUP BY cc.segment1||'.'||segment2||'.'||segment3||'.'||segment4
    Hope this helps.
    Octavio

  • HT2105 how do i transfrer my apple id balance to another account?

    how do i transfer my apple id balance to my wifes account?

    You can't do that yourself. Click here and ask the iTunes Store staff to put it back onto the card; they'll only do this if none of the balance has been spent.
    (97051)

  • Clearing balance in Bank account

    Hi Guys,
    I have bank account with EUR curreny but my local currency INR, now we are closing account and made the clearing document with EUR currency.The clearning document is posted in EUR and now if we go FS10N system is showing some balance in the account INR currency due to exchange rate difference. (Note: Balance is showing only local currency and not EUR currench in Same account).
    It should be go to exchange rate loss/ Gain account, now i can not transfer the amount to exchange rate loss/ Gain account because the account is maintaing in EUR.
    Kindly suggest me in this regard.
    Reg,
    Raj.

    Raja,
    Please use transactin F-03 to clear the trasnactions in your bank ledger.
    In selection screen of F-03 give currency as EUR, since you have 0 balance in EUR currency.Then system will get the net balance in local currency as exchange rate diff.
    May be while doing your F-03 entry, you might get one error also like....
    Exch rate diff accounts not maintained for GL account <your bank GL acc no> for currency INR
    So for this you need to maitntain the exchange rate diff accounts for your bank accounts through OB09.
    This will fix your issue.
    Thanks,
    Srinu
    Edited by: Nathan Genez on Sep 29, 2009 7:43 AM

  • Opening balance and closing balance of BANK accounts

    I would like to see the replica of Pass book (bank statement ie opening balance
    +/- tranactions during the month then closing balance.
    I would like to execute and get these Bank Journals at any point of time for any period/year.
    Is this possible in SAP?
    Thanks a lot for helping on this
    Sridevi

    Hi
    I heard that its not possible even with Z report. is that so? Or do you think its possible with Z report or report painter. Could you tell me the reasons for this?
    Thanks
    Sridevi

  • How to build query which list only active PC's

    Hi guys,
    I have to install SCCM client on many devices in my enviroment. Unfortunately, SCCM has found amny devices which still have accounts in AD but are not used for looong time. I would like to list only devices, which hasen't installed SCCM client yet but are
    active in my enviroment. 
    That is possible? If yes, that will be glad to hear how build this query.
    Thank you.

    If you don't want those not used devices, why don't you stop discovering them. In the
    Active Directory System Discovery there is a tab Options
    in which you can configure to not discover computers account that have not been used.
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • How to build "Query by example" Report?

    I want to create a report which allows user to select which columns to return.
    It is similar to "Query by example" form. Have someone done that before and share me the PL/SQL how to do that?
    Thanks in advance.

    I got the answer, u need to set table.setFilterModel("") and refresh panel collection which contains this table
    whenever u need to make "Query By Example" button of panel collection invisible.

  • How to build query to get tree architecture of self referencing table

    Dear all,
    I have the following table design :
    This is a self referencing table representing a set of SubCategories which can have parent sub categories or not. I did not show here the Category table.
    If the Subcategory has the ParentSubCategory ID = null, then this is a root subcategory otherwise it is a child of a parent sub category.
    What I am looking for is the easy way to display the structure level by ProductCategoryID ?
    Thanks for helps

    you can use a recursive logic based on CTE for that
    something like this would be enough
    ;WITH ProdSubCat_Hiererchy
    AS
    SELECT psc.ProductSubCategoryID,c.CategoryName,psc.ParentSubCategoryID, psc.Name,CAST(psc.Name AS varchar(max)) AS [Path],1 AS [level]
    FROM ProductSubCategory psc
    INNER JOIN Category c
    ON c.CategoryID = psc.ProductCategoryID
    WHERE psc.ParentSubCategoryID IS NULL
    UNION ALL
    SELECT psc.ProductSubCategoryID,c.CategoryName,psc.ParentSubCategoryID, psc.Name,CAST(psch.[Path] + '/' + psc.Name AS varchar(max)) AS [Path],psch.[level] + 1
    FROM ProductSubCategory psc
    INNER JOIN Category c
    ON c.CategoryID = psc.ProductCategoryID
    INNER JOIN ProdSubCat_Hiererchy psch
    ON psch.ProductSubCategoryID = psc.ParentSubCategoryID
    SELECT *
    FROM ProdSubCat_Hiererchy
    ORDER BY LEFT([Path],CHARINDEX('/',[Path]+'/')-1),[Level]
    OPTION (MAXRECURSION 0)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How can i change country while having balance in my account?!

    Hey All,
    my account is under united states . now i want to change it under my country to add credit card but its not allowing me cause i have balance $0.43 ! and i cant use it to buy any thing so what to do ? i need to change the payment method

    If you are now in a different country then you can try contacting iTunes support and ask if they can remove the balance for you : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • I upgraded from firefox 3.6 to firefox 4.0 and now I can't get in to my.msn, fidelity, my banck account.how do I go back to 3.6 my bank account, fidelity, my.msn etc

    when I go to my roboform to signin to my fidelity account firefox won't accept the sign in or password

    Clear the cache and the cookies from sites that cause problems.
    * "Clear the Cache": Firefox > Preferences > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites causing problems: Firefox > Preferences > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • How to pay a foreign vendor on a French Bank Account

    Hi Team
    We have a issue where we need to clear a Forien Vendor.
    So we used a payment menthod say "T" where is marked Foriegn payments allowed.But F110 did not work as the Bank Account was Local .
    Company belongs to France
    Vendor belongs to Swiss
    Vendor Bank Account Belongs to France
    So clearing Foreign vendor with Local Bank Account,is not possible
    So please advice us what are the settings to be done where we can clear the foreign vendor.through F110.using a payment method wich alloes FOrien vendor using Local Bank Account.
    Thanks
    Swetha

    Hi Sujatha,
    All the settings of F110 come From FBZP, have you check the following :
    - FBZP--Ranking Order : is you Bank in the first Rank
    - FBZP--Bank Account : in your case you must have this entry
    House Bank : Name of the Local Bank Account (France)
    Payment method : T
    Currency : CHF
    Bank Subaccount : your bank subaccount
    - FBZP--Available Amounts : Check if you have an available amount for your Bank (France) and Currency (CHF)
    Don't forget to check also if for this foreign vendor we have the payment method ' T ' in the master Data (Tcode : XK03)
    Regards

  • How to specify query timeout

    how to set query timeout in code so that if connection breaks then it can restart immediately
    help me out

    No such thing in Oracle.
    You can time-out a user session but that will not stop a query running on the server. If you want to kill the query you must kill the session running on the server using UNIX/Linux kill, orakill, or alter system kill session and then log in again.
    PS: In the future post version, platform, operating system, etc. when asking questions.

Maybe you are looking for

  • How do i connect to exchange server remote desktop

    Hi, hope someone can point me in the right direction. I have recently purchased a macbook pro and wish to connect to our office server which is a windows exchange server (remote desktop). Which steps do I need to take. Many Thanks, Rob K.

  • 8.2 Update Error Message

    Trying to update a macbook and get the following error: The update "iTunes" can't be saved. A networking error has ocurred. Cannot open file(-3000). Make sure you can connect to the internet and try again. Internet connection is fine and also repaire

  • Transferring music/files from Iphone 3gs to new computer

    Hi I have previously transferred music form my ipod to an old laptop, both have since broken or been updated.... so lost the info for the website yamipod...I have had a look to help move everything but for some reason it doesn't work on my computer!!

  • How to print ALV with full page width used?

    Dear all, I have a report which print out with a small font if some of the fields have a long data content, while there a large white space on the right hand side. After a few test, I think the following cause the problem: 1) The line column is less

  • SAP Enterprise Modeling Applications by IDS Scheer (ARIS)

    Hi, Does anyone know where to find the temporary license key for SAP Enterprise Modeling by IDS Scheer? The documentation in the Service Marketplace directs you to the "download scope" - however I cannot find anything in the download software or in t