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
SELECT SSN, Balance, SUM(Balance) as Total_Balance FROM tablename GROUP BY SSN
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
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?
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,
“To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln
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...
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.
“To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln
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.
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.
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
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.
You need to add a WHERE clause
SELECT [ARMS C&R I].SSN_TIN, Sum([ARMS C&R I].CURRENT_BALANCE) AS SumOfCURRENT_BALANCE FROM [ARMS C&R I] GROUP BY [ARMS C&R I].SSN_TIN WHERE [ARMS C&R I].SSN_TIN <> 000000000 and [ARMS C&R I].SSN_TIN <>111111111 and [ARMS C&R I].SSN_TIN <>999999999;
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
I get a syntax error (missing operator) in query expression
Last edited by jgomez; 10-07-2011 at 10:39 AM.
alansidman's SQL looks pretty good to me. What type of data is your SSN field? Number?
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
Yes number... i think i got it though. waiting for it to finish running. I put "NOT LIKE "*000000000*" in the criteria.
I don't know why i can't select solved on this thread... it works! Thanks a lot guys.
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.
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks