Sub-Total Query

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
I have some data coming from an Oracle database, that I need to recreate in Access. It's much easier to pull the raw data and update the queries there than to have to pull static files from Oracle.

Here's an example:
Excel Workbook
ABCDEFGH
3COMPANY - 701
4LOCATION - TOTAL SMP
5CURRENCY - USD
6PRODUCT LINE - TOTAL PRODUCT LINE
7ACTIVITIES - TOTAL ACTIVITIES
8Year 09Jan 10Feb 10Mar 10Apr 10May 10Jun 10
9SALES.00.00.00.00.00.00.00
10SALES - PRODUCTS AND SERVICES.00.00.00.00.00.00.00
1135000 SALES-SELLING PRICE REGULAR.00.00.00.00.00.00.00
1235001 SALES-LIQUID PRODUCT.00.00.00.00.00.00.00
1335002 SALES-GAS PRODUCT.00.00.00.00.00.00.00
1435004 SALES-EQUIPMENT.00.00.00.00.00.00.00
34FACILITY FEES.00.00.00.00.00.00.00
3535100 SALES-FACILITY FEES.00.00.00.00.00.00.00
36OTHER.00.00.00.00.00.00.00
3735201 SALES-INSURANCE CHARGE.00.00.00.00.00.00.00
49COST OF SALES.00.00.00.00.00.00.00
50COGS GENERAL.00.00.00.00.00.00.00
51INVENTORY COSTS.00.00.00.00.00.00.00
5246000 COGS-COST OF GOODS SOLD.00.00.00.00.00.00.00
5346001 COGS-TRANSFER IN COST OF GOODS SOLD.00.00.00.00.00.00.00
5446002 COGS-TRANSFER OUT OF COST OF GOODS SOLD.00.00.00.00.00.00.00
5546003 FABRICATION VARIANCE.00.00.00.00.00.00.00
5646004 COGS-AVERAGE COST VARIANCE.00.00.00.00.00.00.00
5746005 COGS-INVOICE PRICE VARIANCE.00.00.00.00.00.00.00
5846007 COGS-PURCHASE PRICE VARIANCE.00.00.00.00.00.00.00
5946008 COGS-STANDARD COST VARIANCE.00.00.00.00.00.00.00
SC
Excel 2010

I'm trying to get the Category totals, as well as their individual components. I've been reading a bit about Subtotal queries with SQL, but not really wrapping my head around it at this point.

Any suggestions?

Thanks,
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Smitty Hi,

A suggestion to get you going.

In a database select to create a new query, then select a table and then select the fields in the table, look at the icons at the top and look for the totals icon (It is the Autosum icon that you would use in Excel) this will place in groups as an extra row in the query, then select to change a group to sum or average or min or max, this then gives you groups and totals.

If this works for you then you can look at thge SQL statement via changing the view of the query, you then have the code you can adapt.

Hope this helps you!
 
Upvote 0
Smitty,

Are these queries an end-point or a halfway house? If the queries are the end-point and the next step is to create a report, check out the reporting tools in Access. You can sort, group and filter to create just about any subtotal you want. Assuming that the screenshot is desired output, a report will handle that, no problem.

Denis
 
Upvote 0
Thanks guys - I'll look at both options.

Denis, yes these are the end point before being pulling into Excel to generate reports based off of those results. I had thought about reports, but decided against it as these are for data references only.

I was able to turn my crosstab query into a Pivot Table and export it, so as long as I can refresh it, it should suffice.

Thanks again!

(I love learning new stuff!)
 
Upvote 0

Forum statistics

Threads
1,221,707
Messages
6,161,411
Members
451,704
Latest member
rvan07

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top