D
DavidBonsall
I am havign a very miserable Sunday afternoon!
I have a table [table1] of patient samples. The fields are [Patient], [Date]
and [Sample] The samples taken on the same date can be either "Plasma" or
"Cells" etc. I would like to know how many "Plasma" samples and "Cell"
samples (etc) I have for each patient on each date.
I can find out how many "Cells" I have for each patient on a particular
date, using the following query:
SELECT [table1].[Patient], [table1].[date], Count([table1].Sample) AS
TotalCells
FROM [table1]
GROUP BY [table1].[Patient], [table1].[date], [table1].Sample
HAVING ((([table1].Sample)="Cells"));
But when I turn this into a union query to display the total number of
Plasma samples (same table, same field, different value). The query returns
exactly the same table ie. with a "TotalCells" column but not a "TotalPlasma"
column. Would you, could you, please explain why?
SELECT [table1].[Patient], [table1].[date], Count([table1].Sample) AS
TotalCells
FROM [table1]
GROUP BY [table1].[Patient], [table1].[date], [table1].Sample
HAVING ((([table1].Sample)="Cells"))
UNION SELECT [table1].[Patient], [table1].[date], Count([table1].Sample) AS
TotalPlasma
FROM [table1]
GROUP BY [table1].[Patient], [table1].[date], [table1].Sample
HAVING ((([table1].Sample)="Plasma"));
Kindest Regards
David
I have a table [table1] of patient samples. The fields are [Patient], [Date]
and [Sample] The samples taken on the same date can be either "Plasma" or
"Cells" etc. I would like to know how many "Plasma" samples and "Cell"
samples (etc) I have for each patient on each date.
I can find out how many "Cells" I have for each patient on a particular
date, using the following query:
SELECT [table1].[Patient], [table1].[date], Count([table1].Sample) AS
TotalCells
FROM [table1]
GROUP BY [table1].[Patient], [table1].[date], [table1].Sample
HAVING ((([table1].Sample)="Cells"));
But when I turn this into a union query to display the total number of
Plasma samples (same table, same field, different value). The query returns
exactly the same table ie. with a "TotalCells" column but not a "TotalPlasma"
column. Would you, could you, please explain why?
SELECT [table1].[Patient], [table1].[date], Count([table1].Sample) AS
TotalCells
FROM [table1]
GROUP BY [table1].[Patient], [table1].[date], [table1].Sample
HAVING ((([table1].Sample)="Cells"))
UNION SELECT [table1].[Patient], [table1].[date], Count([table1].Sample) AS
TotalPlasma
FROM [table1]
GROUP BY [table1].[Patient], [table1].[date], [table1].Sample
HAVING ((([table1].Sample)="Plasma"));
Kindest Regards
David