T
tvh
I have created the following Union which gives me three columns:
tbleiLastName, # of Records and Position. How would I change the statement
so that I have the record count under each position?
So, from this:
tbleiLastName # of Records Position
Smith 10 Lead Position
Smith 3 Assistant
Smith 1 2nd Assistant
Jones 5 Lead Position
Jones 2 Assistant
Jones 2 2nd Assistant
To This:
Last Name Lead Position Assistant 2nd Assistant
Smith 10 3 1
Jones 5 2 2
SELECT tblEmployees.tbleiLastName,
Count(tblWorkOrderDetail.[tblwodWorkOrder#]) AS [# of Records], "Lead
Position" AS [Position]
FROM tblWorkOrderDetail INNER JOIN tblEmployees ON
tblWorkOrderDetail.tblwodLeadTechnician = tblEmployees.tbleiEmployeeID
GROUP BY tblEmployees.tbleiLastName
UNION SELECT tblEmployees.tbleiLastName,
Count(tblWorkOrderDetail.[tblwodWorkOrder#]) AS [# of Records], "Assistant"
AS [Position]
FROM tblWorkOrderDetail INNER JOIN tblEmployees ON
tblWorkOrderDetail.tblwodAssistant = tblEmployees.tbleiEmployeeID
GROUP BY tblEmployees.tbleiLastName
UNION SELECT tblEmployees.tbleiLastName,
Count(tblWorkOrderDetail.[tblwodWorkOrder#]) AS [# of Records], "2nd
Assistant" AS [Position]
FROM tblWorkOrderDetail INNER JOIN tblEmployees ON
tblWorkOrderDetail.tblwod2ndAssistant = tblEmployees.tbleiEmployeeID
GROUP BY tblEmployees.tbleiLastName;
Thanks
tbleiLastName, # of Records and Position. How would I change the statement
so that I have the record count under each position?
So, from this:
tbleiLastName # of Records Position
Smith 10 Lead Position
Smith 3 Assistant
Smith 1 2nd Assistant
Jones 5 Lead Position
Jones 2 Assistant
Jones 2 2nd Assistant
To This:
Last Name Lead Position Assistant 2nd Assistant
Smith 10 3 1
Jones 5 2 2
SELECT tblEmployees.tbleiLastName,
Count(tblWorkOrderDetail.[tblwodWorkOrder#]) AS [# of Records], "Lead
Position" AS [Position]
FROM tblWorkOrderDetail INNER JOIN tblEmployees ON
tblWorkOrderDetail.tblwodLeadTechnician = tblEmployees.tbleiEmployeeID
GROUP BY tblEmployees.tbleiLastName
UNION SELECT tblEmployees.tbleiLastName,
Count(tblWorkOrderDetail.[tblwodWorkOrder#]) AS [# of Records], "Assistant"
AS [Position]
FROM tblWorkOrderDetail INNER JOIN tblEmployees ON
tblWorkOrderDetail.tblwodAssistant = tblEmployees.tbleiEmployeeID
GROUP BY tblEmployees.tbleiLastName
UNION SELECT tblEmployees.tbleiLastName,
Count(tblWorkOrderDetail.[tblwodWorkOrder#]) AS [# of Records], "2nd
Assistant" AS [Position]
FROM tblWorkOrderDetail INNER JOIN tblEmployees ON
tblWorkOrderDetail.tblwod2ndAssistant = tblEmployees.tbleiEmployeeID
GROUP BY tblEmployees.tbleiLastName;
Thanks