Solved

Need output in the attached format and finally to be exported to Excel

Posted on 2009-07-10
10
397 Views
Last Modified: 2012-05-07
Need output in the attached format and finally to be exported to Excel
Current result is obtained using the cross tab query in MS Access.
Expected result should also include totals for each row grouped by Supervisor and the grand total at the end.

So that finally it can be generated in Excel.
Query14.doc
0
Comment
Question by:Jsara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 2

Expert Comment

by:billb1057
ID: 24826578
You could do it with nested queries.
First sum all the supervisors.
Then use that as a table to sumarize at the supervisor code setting.
Then union or append the results.
0
 

Author Comment

by:Jsara
ID: 24826609
How to get the totals beneath each supervisor. Can you please help me with the code.
0
 
LVL 2

Accepted Solution

by:
billb1057 earned 500 total points
ID: 24826751
Try this.
I called the original table tbl_supervisors

SELECT tbl_supervisors.supervisor, "Total" AS Sname, Sum(tbl_supervisors.Total) AS SumOfTotal, Sum(tbl_supervisors.Categ1) AS SumOfCateg1, Sum(tbl_supervisors.[Categ 2]) AS [SumOfCateg 2], Sum(tbl_supervisors.[Categ 3]) AS [SumOfCateg 3], Sum(tbl_supervisors.[Categ 4]) AS [SumOfCateg 4], Sum(tbl_supervisors.[Categ 5]) AS [SumOfCateg 5], Sum(tbl_supervisors.[Categ 6]) AS [SumOfCateg 6], Sum(tbl_supervisors.[Categ 7]) AS [SumOfCateg 7]
FROM tbl_supervisors
GROUP BY tbl_supervisors.supervisor, "Total"
Union
SELECT tbl_supervisors.supervisor, tbl_supervisors.name, tbl_supervisors.Total, tbl_supervisors.Categ1, tbl_supervisors.[Categ 2], tbl_supervisors.[Categ 3], tbl_supervisors.[Categ 4], tbl_supervisors.[Categ 5], tbl_supervisors.[Categ 6], tbl_supervisors.[Categ 7]
FROM tbl_supervisors;

Open in new window

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 2

Expert Comment

by:billb1057
ID: 24829005
You can just replace the "tbl_supervisors" with the name of your cross-tab query.
Also, when you're done -- use the Transfer Spreadsheet method to export the final result to Excel.
Let me know what you think -- it worked fine for me.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24829700
1. This can be done in Access, as billb1057 has shown.
So the obvious question is, why can't this stay in Access?

2. When you export this to Excel the totals will be "Hard-Coded" (Not formulas)
So if you ever want to change a value, you will have to delete the Hardcoded value and insert a formula.
So why not just import the raw data and do the formula in Excel straight away?

JeffCoachman
0
 

Author Comment

by:Jsara
ID: 24849796
I tried billb1057' solution - not getting the expected results, not sure where I am going wrong.
Can a sample of access db posted.

To answer - boag2000: I am not familiar with excel much - could you post the working exampl.
0
 
LVL 2

Expert Comment

by:billb1057
ID: 24849983
Jsara -- you can post the db or the SQL.
0
 

Author Comment

by:Jsara
ID: 24850242
SELECT test2.supervisor, "Total" AS Sname, Sum(test2.Total) AS SumOfTotal, Sum(test2.[5779]) AS SumOf5779, Sum(test2.ERU) AS [SumOfERU], Sum(test2.FA) AS [SumOfFA], Sum(test2.LIM) AS [SumOfLIM], Sum(test2.NFA) AS SumOfNFA, Sum(test2.TA) AS SumOfTA, Sum(test2.UF) AS [SumOfUF]
FROM test2
GROUP BY test2.supervisor, "Total"
UNION SELECT test2.[supervisor], test2.[name], test2.Total, test2.[5779], test2.[ERU], test2.[FA], test2.[LIM], test2.[NFA], test2.[TA], test2.[UF]
FROM test2;

Query15.doc
0
 
LVL 2

Expert Comment

by:billb1057
ID: 24850582
That worked for me.  What happens when you try it?
0
 
LVL 2

Expert Comment

by:billb1057
ID: 24850653
Ok, the one difference my be that this SQL assumes that "test2" is a table.  The problem might be because you're running it off of a crosstab query first (which is already summing columns).
One option might be to create a make-table query first and then run this SQL on it.
I'll check to see what happens with a crosstab.
0

Featured Post

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question