Union Queries

  • Thread starter Thread starter AGOKP4
  • Start date Start date
A

AGOKP4

Hi,

I sit possible to make union queries from crosstab queries? I have tried a
couple of times without luck. The queries I hope to combine are listed below.

Thanks

TRANSFORM Count([Enrolled F Qry].Tenofovir) AS CountOfTenofovir
SELECT [Enrolled F Qry].[Creatinine Group], Count([Enrolled F
Qry].[Creatinine Group]) AS [CountOfCreatinine Group]
FROM [Enrolled F Qry]
GROUP BY [Enrolled F Qry].[Creatinine Group]
PIVOT [Enrolled F Qry].Tenofovir;

TRANSFORM Count([Enrolled M Qry].[Study ID]) AS [CountOfStudy ID]
SELECT [Enrolled M Qry].[Creatinine Group], Count([Enrolled M Qry].[Study
ID]) AS [Total Of Study ID]
FROM [Enrolled M Qry]
GROUP BY [Enrolled M Qry].[Creatinine Group]
PIVOT [Enrolled M Qry].Tenofovir;

TRANSFORM Count([Enrolled Qry].Race) AS CountOfRace
SELECT [Enrolled Qry].Ethnicity, Count([Enrolled Qry].Ethnicity) AS
CountOfEthnicity
FROM [Enrolled Qry]
GROUP BY [Enrolled Qry].Ethnicity
PIVOT [Enrolled Qry].Race;
 
You can't use "UNION" in a crosstab query. You should be able to UNION the
results of the crosstabs if the number of columns is always the same.

SELECT *
FROM crosstab1
UNION
SELECT *
FROM crosstab2
UNION
SELECT *
FROM crosstab3;
 
Back
Top