I've got a crosstab query that other queries depend on, unfortunatly I run into problems if the crosstab query returns less columns than the other queries are expecting!
Crosstab is:
Which returns something like
emp no 0 1 2 3 4 5 as the headings, and then each employee and a 1 under their level.
One of the queries that depends on this is:
Is there a nice way to get this query to work whatever the number of columns? or am i hoping for far too much
Crosstab is:
Code:
TRANSFORM Count(EmpLevel.EmpNo) AS CountOfEmpNo
SELECT EmpLevel.EmpNo
FROM EmpLevel
GROUP BY EmpLevel.EmpNo
PIVOT EmpLevel.Level;
emp no 0 1 2 3 4 5 as the headings, and then each employee and a 1 under their level.
One of the queries that depends on this is:
Code:
SELECT Sum(EmpLevel_Crosstab.[0]) AS Exec, Sum(EmpLevel_Crosstab.[1]) AS [Level 1], Sum(EmpLevel_Crosstab.[2]) AS [Level 2], Sum(EmpLevel_Crosstab.[3]) AS [Level 3], Sum(EmpLevel_Crosstab.[4]) AS [Level 4], Sum(EmpLevel_Crosstab.[5]) AS [Level 5], Sum(EmpLevel_Crosstab.[6]) AS [Level 6], Sum(EmpLevel_Crosstab.[7]) AS [Level 7]
FROM EmpLevel_Crosstab;