Thanks for replying Rick. Here's the details you requested with a few more details.
I am using Visual Studio to create the report.
Here is the first query:
SELECT [Job No_], [Global Dimension 2 Code], [Posting Date], [Document No_], Description, [Total Cost], [Total Price], LEFT([Global Dimension 2 Code], 1)
AS Expr1, [Source Name]
FROM [Company$Job Ledger Entry]
WHERE ([Job No_] = '0218') AND ([Posting Date] BETWEEN '20080601' AND '20080630')
ORDER BY [Global Dimension 2 Code]
(For testing and getting this up and running I removed the user inputs and used the examples shown in the WHERE statement, in this case Job 0218 for June 2008).
[Global Dimension 2 Code] is the cost code and is of the format 101, 102, 103, 201, 202, 301, 302 etc.
In the Layout section I added a table and inserted two Groups. The first was grouped by Expr1 to group 100, 200, 300 etc. The second was by [Global Dimension 2 Code]. This way I can total each cost code and each section. The columns are Posting Date, Source, Document No, Description and Cost (which is Total Cost + Total Price). All fine.
As mentioned before I also want to add next to each cost code total the sum of the costs BEFORE the entered dates. With our example, all costs before June. So you can see for any given code the costs before June, the June costs then a final column in which they are added together.
To get the data I created a second query called RunningCost:
SELECT [Global Dimension 2 Code] AS RCGD2Code, [Total Cost] AS RCTotalCost, [Total Price] AS RCTotalPrice, LEFT([Global Dimension 2 Code], 1)
AS RCExpr1
FROM [Company$Job Ledger Entry]
WHERE ([Job No_] = '0218') AND ([Posting Date] BETWEEN '20010101' AND '20080531')
ORDER BY RCGD2Code
I now need to add the previous cost (RCTotalCost + RCTotalPrice) for each cost code into the table. My problem is I cannot get it to recognise the group structure in the table. With the output being the TOTAL total cost for everything not just the cost code total cost or section total.
Recap of the table structure:
First grouped into cost code sections, 100, 200, 300 etc
Then grouped in to each cost code 101, 102, 201, 202 etc
Columns for the cost code ectries are:
Posting Date, Source, Document No, Description, Cost (Total Cost + Total Price)
A cost code total at the end of each code and another at the end of each section
(All this works fine)
Now need to enter previous cost code totals next to the current totals
Further column to add these together.
Cheers for your time and help,
John
Main Topics
Browse All Topics





by: Rick_RickardsPosted on 2008-07-29 at 22:32:40ID: 22117693
Basically it sounds like you'd like data from one query to be included inside another. Can that be done (usually). The explanation could be a bit to follow and certainly a lot clearer if it included the solution. Can you post
1) post both queries
2) Identify which is which and
3) Identify what columns you'd like included in the finished product?