473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Aggregation of several columns in one query

44
Hi,
I'm working on a access database to automate our Staff procedures a bit. One part is to select several informations from a table and to aggregate some of the outputs.

For example:
50 people are in the department
45 are current staff (15 business adviser, 15 financial planner and 15 sales officer)
3 are on extended leave (1 business adviser and 2 financial planner)
1 is resigned (1 sales officer)
and 1 moved to another department (1 sales officer)

I need the aggregation of all current, extended leave and resigned (contains resigned and moved) staff per job title.

I created a query with the title column and than created 4 new columns with the sum of all current, extended leave, resigned and moved staff. But I can't manage to get the aggregation for the resigned and moved staff.

The below example is only a shorted version. Generally I have 5-7 status to be aggregated into one.

Does anybody has an idea what I can do?

If I work with excel, I would probably do a horizontal aggregation. Easy...but in access I fail.

Thanks for your help.
Sep 11 '06 #1
5 2349
MMcCarthy
14,534 Expert Mod 8TB
There is no example attached. The only way we can help you is if you post the full query code.



Hi,
I'm working on a access database to automate our Staff procedures a bit. One part is to select several informations from a table and to aggregate some of the outputs.

For example:
50 people are in the department
45 are current staff (15 business adviser, 15 financial planner and 15 sales officer)
3 are on extended leave (1 business adviser and 2 financial planner)
1 is resigned (1 sales officer)
and 1 moved to another department (1 sales officer)

I need the aggregation of all current, extended leave and resigned (contains resigned and moved) staff per job title.

I created a query with the title column and than created 4 new columns with the sum of all current, extended leave, resigned and moved staff. But I can't manage to get the aggregation for the resigned and moved staff.

The below example is only a shorted version. Generally I have 5-7 status to be aggregated into one.

Does anybody has an idea what I can do?

If I work with excel, I would probably do a horizontal aggregation. Easy...but in access I fail.

Thanks for your help.
Sep 11 '06 #2
PEB
1,418 Expert 1GB
Hi,

You can do a Crosstab query to perform your task...

So You select Crosstab from Query menu

You select the field JobTitle and you assign it AS RowData

You Select the field that shows the status /moved, resigned, and other/
And you assign it as Column DATA

Copy an other time this field
under it assign that is value and that it have to run the count function instaed of grouped by


When you open your crosstab you will see your staff countet by job title and status..
Sep 11 '06 #3
isetea
44
Hi! Sorry here is the sql. The bold sentence is a count I tried, but it was not working. Thanks.

SELECT
Title, Sum(Resigned) AS SumOfResigned, Sum(Terminated) AS SumOfTerminated, Sum([Retired Ill Health]) AS [SumOfRetired Ill Health], Sum(Redundant) AS SumOfRedundant, Sum(Moved) AS SumOfMoved,

Sum([Resigned]+[Terminated]+[Retired Ill Health]+[Redundant]+[Moved]) AS Attrition

FROM
qry_Union_All_Status_for_Distribution_Report

GROUP BY
Title;
Sep 12 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
Try this:

SELECT
Title, Sum(Resigned) AS SumOfResigned, Sum(Terminated) AS SumOfTerminated, Sum([Retired Ill Health]) AS [SumOfRetired Ill Health], Sum(Redundant) AS SumOfRedundant, Sum(Moved) AS SumOfMoved,
Sum (SumOfResigned + SumOfTerminated + [SumOfRetired Ill Health] + SumOfRedundant + SumOfMoved) As Attrition FROM
qry_Union_All_Status_for_Distribution_Report GROUP BY Title;


If that doesn't work try following query with a second query.

SELECT Title, Sum (SumOfResigned + SumOfTerminated + [SumOfRetired Ill Health] + SumOfRedundant + SumOfMoved) As Attrition From Query1 Group By Title;
Sep 12 '06 #5
isetea
44
Thanks. I used two queries and now it's working...
:)
Sep 12 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chris K | last post by:
I am relatively new to C++ and hope that this question is relevant. I have spent some time at the local library and some time on dejanews, but have no decided to go ahead with my question, since...
0
by: Eric | last post by:
Hello, I'm completely new to c# and the .NET Framework, so perhaps there is an obvious answer to this. But I have done searches in MSDN and news groups and not found anything that really...
1
by: Nice Chap | last post by:
Aggregation in COM was defined as 'Exposing an interface of an inner object by the outer object as though it were an interface of the outer object'. Is this type of aggregation possible in c#? ...
5
by: John Wood | last post by:
Let's say you're provided with an instance of a class. The instantiation takes place in another module that you have no control over. However, you've extended that class with your own value-added...
4
by: cmrchs | last post by:
Hi, how do I implement aggregation and how composition in C# ? When I say : an Airplane has a Pilot then I use aggregation but when I say : an Airplane has a Cockpit then I use composition. How...
2
by: Jozsef Bekes | last post by:
Hi, I would like to implement aggregation in C#, therefore I'd need to implement the queryinterface COM function of a class. I am not sure whether this can be done, and if yes where to start. If...
4
by: Frederik Vanderhaegen | last post by:
Hi, Can anyone explain me the difference between aggregation and composition? I know that they both are "whole-part" relationships and that composition parts are destroyed when the composition...
23
by: SenthilVel | last post by:
Hi Can any one let me know the websites/Pdf for learning Aggragation in C#?? Thanks Senthil
4
by: incubeme | last post by:
Hi, I would like to get an aggregation from several different tables, but don't know how to get. I have tried many different options, but no success. Hopefully someone here can help me out? The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.