J
John Melbourne
I'm trying to add a dimension to my count but when I add a group by I get the
additional rows but the counts are all the same within the columns. My table
contains the name, sex, state, workplace and Id of employees. I currently
have the following code that gives me one dimension, I want to add by
workplace.
ID NAME M/F STATE WORK
0001 TED M 2 OFFICE
0002 PAT F 3 OFFICE
0003 JOHN M 3 WORKSHOP
0004 MARY F 2 FIELD
0005 CLARE F 3 OFFICE
0006 JIM M 2 FIELD
Current count looks like
MNNSW FENSW MNVIC FEVIC
2 1 1 2
Would like to
MNNSW FENSW MNVIC FEVIC TOTAL
FIELD 1 1 2
OFFICE 1 2 3
WORKSHOP 1 1
TOTAL 2 1 1 2 6
My current code is
SELECT Count([tblAfAct].fldID) AS [FE-MALE COUNT],
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "2") AS MNNSW,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "2") AS FENSW,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "3") AS MNVIC,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "3") AS FEVIC,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "4") AS MNQLD,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "4") AS FEQLD,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "5") AS MNSA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "5") AS FESA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "6") AS MNWA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "6") AS FEWA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "7") AS MNTAS,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "7") AS FETAS
FROM [TEST-Q-END-VBA];
Thanks all
additional rows but the counts are all the same within the columns. My table
contains the name, sex, state, workplace and Id of employees. I currently
have the following code that gives me one dimension, I want to add by
workplace.
ID NAME M/F STATE WORK
0001 TED M 2 OFFICE
0002 PAT F 3 OFFICE
0003 JOHN M 3 WORKSHOP
0004 MARY F 2 FIELD
0005 CLARE F 3 OFFICE
0006 JIM M 2 FIELD
Current count looks like
MNNSW FENSW MNVIC FEVIC
2 1 1 2
Would like to
MNNSW FENSW MNVIC FEVIC TOTAL
FIELD 1 1 2
OFFICE 1 2 3
WORKSHOP 1 1
TOTAL 2 1 1 2 6
My current code is
SELECT Count([tblAfAct].fldID) AS [FE-MALE COUNT],
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "2") AS MNNSW,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "2") AS FENSW,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "3") AS MNVIC,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "3") AS FEVIC,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "4") AS MNQLD,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "4") AS FEQLD,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "5") AS MNSA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "5") AS FESA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "6") AS MNWA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "6") AS FEWA,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "M" AND F01STC = "7") AS MNTAS,
(SELECT COUNT([tblAfAct].fldMF)
FROM [tblAfAct] WHERE fldMF = "F" AND F01STC = "7") AS FETAS
FROM [TEST-Q-END-VBA];
Thanks all