Crosstab Combine

J

Jeremy Noland

Here is the SQL for my Crosstab :

TRANSFORM IIf(IsNull(Count([Sex])),0,Count([Sex])) AS DaVal
SELECT Background_Table.Country
FROM Background_Table, Training_Table
WHERE ((([Background_Table].[First_Name] &
[Background_Table].[Last_Name])=[Training_Table].
[First_Name] & [Training_Table].[Last_Name]) AND
((Background_Table.Sex)="M" Or (Background_Table.Sex)="F"))
GROUP BY Background_Table.Country
PIVOT [Training_Type] & [Sex];

So far I have what I want...now I want to combine
different Training_Types AND get the sum of the two in
replacement :

SELECT Report07_SummaryCross.Country, Sum([CourseM] And
[Distance LearningM] And [MentoringM]) AS Short_Male, Sum
([CourseF] And [MentoringF]) AS Short_Female,
Report07_SummaryCross.DrPHF, Report07_SummaryCross.DrPHM,
Sum([MPHM] And [MSPHM]) AS MSMPH_Male
FROM Report07_SummaryCross
GROUP BY Report07_SummaryCross.Country,
Report07_SummaryCross.DrPHF, Report07_SummaryCross.DrPHM;

Anyone help me, as Here I find out the Sum function
doesn't work as I want it to. (negative numbers, etc.) I
need a function that will calculate across multiple fields
from the crosstab query.

Thanks...
 
E

Eric Cárdenas [MSFT]

Here is the SQL for my Crosstab :
TRANSFORM IIf(IsNull(Count([Sex])),0,Count([Sex])) AS DaVal
SELECT Background_Table.Country
FROM Background_Table, Training_Table
WHERE ((([Background_Table].[First_Name] &
[Background_Table].[Last_Name])=[Training_Table].
[First_Name] & [Training_Table].[Last_Name]) AND
((Background_Table.Sex)="M" Or (Background_Table.Sex)="F"))
GROUP BY Background_Table.Country
PIVOT [Training_Type] & [Sex];

So far I have what I want...now I want to combine
different Training_Types AND get the sum of the two in
replacement :

SELECT Report07_SummaryCross.Country, Sum([CourseM] And
[Distance LearningM] And [MentoringM]) AS Short_Male, Sum
([CourseF] And [MentoringF]) AS Short_Female,
Report07_SummaryCross.DrPHF, Report07_SummaryCross.DrPHM,
Sum([MPHM] And [MSPHM]) AS MSMPH_Male
FROM Report07_SummaryCross
GROUP BY Report07_SummaryCross.Country,
Report07_SummaryCross.DrPHF, Report07_SummaryCross.DrPHM;

Anyone help me, as Here I find out the Sum function
doesn't work as I want it to. (negative numbers, etc.) I
need a function that will calculate across multiple fields
from the crosstab query.

Thanks...
--------------------
It would be easier if you just CREATE A NESTED QUERY:

- Create the query with the crosstab results;

- Create another query based on the first query, to tally across multiple
fields.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top