A
Andy
I have a select query that runs off a crosstab query. Within the cross tab
query, the column heading can generate either two or three columns (depending
on the data content), say A,B &C.
There are occassions when all 3 of these columns will be present and
sometimes when just A&B are present. When C is missing, my select query falls
over as it cannot find C to report on. Can I re-write in anyway to let the
select query report either way?
This is my select query SQL (C relates to the Unknown_CS field): SELECT
[q_Clock Stop Counts by Specialty].[Specialty Code], [q_Clock Stop Counts by
Specialty].Spec_Desc, [q_Clock Stop Counts by Specialty].Unknown_CS AS Expr1,
[q_Clock Stop Counts by Specialty].[<=18 Weeks], [q_Clock Stop Counts by
Specialty].[>18 Weeks], IIf([q_Clock Stop Counts by Specialty]![>18 Weeks] Is
Null,1,IIf([q_Clock Stop Counts by Specialty]![<=18 Weeks] Is Null,0,[q_Clock
Stop Counts by Specialty]![<=18 Weeks]/([q_Clock Stop Counts by
Specialty]![<=18 Weeks]+[q_Clock Stop Counts by Specialty]![>18 Weeks]))) AS
[Compliancy (%age)]
FROM [q_Clock Stop Counts by Specialty]
GROUP BY [q_Clock Stop Counts by Specialty].[Specialty Code], [q_Clock Stop
Counts by Specialty].Spec_Desc, [q_Clock Stop Counts by
Specialty].Unknown_CS, [q_Clock Stop Counts by Specialty].[<=18 Weeks],
[q_Clock Stop Counts by Specialty].[>18 Weeks], IIf([q_Clock Stop Counts by
Specialty]![>18 Weeks] Is Null,1,IIf([q_Clock Stop Counts by Specialty]![<=18
Weeks] Is Null,0,[q_Clock Stop Counts by Specialty]![<=18 Weeks]/([q_Clock
Stop Counts by Specialty]![<=18 Weeks]+[q_Clock Stop Counts by
Specialty]![>18 Weeks])));
query, the column heading can generate either two or three columns (depending
on the data content), say A,B &C.
There are occassions when all 3 of these columns will be present and
sometimes when just A&B are present. When C is missing, my select query falls
over as it cannot find C to report on. Can I re-write in anyway to let the
select query report either way?
This is my select query SQL (C relates to the Unknown_CS field): SELECT
[q_Clock Stop Counts by Specialty].[Specialty Code], [q_Clock Stop Counts by
Specialty].Spec_Desc, [q_Clock Stop Counts by Specialty].Unknown_CS AS Expr1,
[q_Clock Stop Counts by Specialty].[<=18 Weeks], [q_Clock Stop Counts by
Specialty].[>18 Weeks], IIf([q_Clock Stop Counts by Specialty]![>18 Weeks] Is
Null,1,IIf([q_Clock Stop Counts by Specialty]![<=18 Weeks] Is Null,0,[q_Clock
Stop Counts by Specialty]![<=18 Weeks]/([q_Clock Stop Counts by
Specialty]![<=18 Weeks]+[q_Clock Stop Counts by Specialty]![>18 Weeks]))) AS
[Compliancy (%age)]
FROM [q_Clock Stop Counts by Specialty]
GROUP BY [q_Clock Stop Counts by Specialty].[Specialty Code], [q_Clock Stop
Counts by Specialty].Spec_Desc, [q_Clock Stop Counts by
Specialty].Unknown_CS, [q_Clock Stop Counts by Specialty].[<=18 Weeks],
[q_Clock Stop Counts by Specialty].[>18 Weeks], IIf([q_Clock Stop Counts by
Specialty]![>18 Weeks] Is Null,1,IIf([q_Clock Stop Counts by Specialty]![<=18
Weeks] Is Null,0,[q_Clock Stop Counts by Specialty]![<=18 Weeks]/([q_Clock
Stop Counts by Specialty]![<=18 Weeks]+[q_Clock Stop Counts by
Specialty]![>18 Weeks])));