+ Reply to Thread
Results 1 to 15 of 15

summing balance for customers

  1. #1
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    summing balance for customers

    Hi there got a query that has about 1000 records... but is made up about 400 customers. I would like to add the balance of each customer if possible... ex:

    Coulmn A Column B
    SSN Balance

    222-22-2222 $500.00
    111-11-1111 $600.00
    222-22-2222 $1,000.00
    222-22-2222 $300.00

    so the end result would be:

    Coulmn A Column B Column C
    SSN Balance Total Balance
    222-22-2222 $500.00 $1,800.00
    111-11-1111 $600.00 $600.00
    222-22-2222 $1,000.00 $1,800.00
    222-22-2222 $300.00 $1,800.00


    Anyone know how to do this??? I know I can create a report to do this but I'd like it in a query...
    Last edited by ConneXionLost; 10-07-2011 at 03:43 PM. Reason: Marked as SOLVED

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: summing balance for customers

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    I know this might cause you to think less of me but by code you mean??? I don't think you mean to place in the query design right?

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: summing balance for customers

    Actually, yes, that is what Dave means. He's given you the SQL version of a sample query that will provide what you've asked. (Except for the "tablename" of course.)

    Have a look here to see how to get to the SQL in the Access Query Designer.

    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  5. #5
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    This is what i came up with then...

    SELECT MRT_D_ACCOUNTS.TAX_ID, SUM(Current_Balance) AS Total
    FROM MRT_F_ACCOUNTS GROUP BY TAX_ID;

    I get:

    Syntax error in query expression 'Select MRT_D_ACCOUNTS.TAX_ID'.

    Don't know why i got this...

  6. #6
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: summing balance for customers

    A possible cause would be in the different spelling for your table name:

    MRT_D_ACCOUNTS; vs,
    MRT_F_ACCOUNTS.

    They should be the same.

  7. #7
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    well the tax id is from the D_accounts table & the balance is from the F_accounts... i modified by taking the d_accounts table.

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: summing balance for customers

    If you pull data from two tables at once, you need to list them both in the FROM clause, and you need to specify the tables' relationship to each other (the JOIN).

    Have a look at the tutorials and instructionals at W3C, they will help you understand who to construct SQL statements.

  9. #9
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    What i have attached works great! The only thing that I can't figure out is where & how to exclude SSN/TIN's that are 000000000, 100000000 & 999999999.

    Not sure if anyone can help w/that... i'm getting the hang of this so please be patient.
    Attached Files Attached Files

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: summing balance for customers

    You need to add a WHERE clause

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  11. #11
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    I get a syntax error (missing operator) in query expression
    Last edited by jgomez; 10-07-2011 at 10:39 AM.

  12. #12
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: summing balance for customers

    alansidman's SQL looks pretty good to me. What type of data is your SSN field? Number?

  13. #13
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    Yes number... i think i got it though. waiting for it to finish running. I put "NOT LIKE "*000000000*" in the criteria.

  14. #14
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: summing balance for customers

    I don't know why i can't select solved on this thread... it works! Thanks a lot guys.

  15. #15
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: summing balance for customers

    From the forum rules
    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1