J
John
I have 4 tables containing information I need to publish. I have been unable
to write a query that collects all of the required information.
Table 1 "ResponsePlanList" fields =
ID
PlanID = "Foreign Key to Table 2 "ResponsePlan.ID"
PrimaryCode
PrimaryID = "Foreign Key to either Table 3 = "Resource.ID" when
"ResponsePlanList.PrimaryCode" valueor = 1 or Table 4 = "Capabilities.ID"
when "ResponsePlanList.PrimaryCode" value = 0
PrimaryOrder
SubstituteCode
SubstituteID = "Foreign Key to either Table 3 = "Resource.ID" when
"ResponsePlanList.SubstituteCode" value or = 1 or Table 4 = "Capabilities.ID"
when "ResponsePlanList.SubstituteCode" value = 0
SubstituteTime
AdditionalCode
AdditionalID = "Foreign Key to either Table 3 = "Resource.ID" when
"ResponsePlanList.AdditionalCode value or = 1 or Table 4 = "Capabilities.ID"
when "ResponsePlanList.AdditionalCode value = 0
AdditionalTime
Table 2 "ResponsePlan" fields =
ID
Name
JurisdictionID
AlarmLevel
Group_ID
DispatchLevelID
Active
AutomaticDispatchEnabled
Table 3 = "Resource" fields =
ID
Code
Description
Table 4 = "Capabilities" fields =
ID
Code
Description
The Table 1 "ResponsePlanList" fields, PrimaryCode, SubstituteCode and
AdditionalCode are either 0 which refers to Table 4 "Capabilities.ID" or 1
which refers to Table 3 = "Resource.ID".
My report needs to show:
Table 2 "ResponsePlan" fields; Name, AlarmLevel
AND
Table 1 "ResponsePlanList" fields; PrimaryOrder
AND
WHEN Table 1 "ResponsePlanList.PrimaryCode" = 1
Table 3 = "Resource" fields; ID, Code, Description,
OR
WHEN Table 1 "ResponsePlanList.PrimaryCode" = 0
Table 4 = "Capabilities" fields ID, Code, Description
AND
WHEN Table 1 "ResponsePlanList.SubstituteCode" = 1
Table 3 = "Resource" fields; ID, Code, Description,
OR
WHEN Table 1 "ResponsePlanList.SubstituteCode" = 0
Table 4 = "Capabilities" fields ID, Code, Description
AND "ResponsePlanList.SubstituteTime"
UNLESS "ResponsePlanList.SubstituteID" = -1
AND
WHEN Table 1 "ResponsePlanList.AdditionalCode" = 1
Table 3 = "Resource" fields; ID, Code, Description,
OR
WHEN Table 1 "ResponsePlanList.AdditionalCode" = 0
Table 4 = "Capabilities" fields ID, Code, Description
AND "ResponsePlanList.AdditionalTime"
UNLESS "ResponsePlanList.AdditionalID" = -1
Any help is appreciated, I have been all around this for 2 days straight.
to write a query that collects all of the required information.
Table 1 "ResponsePlanList" fields =
ID
PlanID = "Foreign Key to Table 2 "ResponsePlan.ID"
PrimaryCode
PrimaryID = "Foreign Key to either Table 3 = "Resource.ID" when
"ResponsePlanList.PrimaryCode" valueor = 1 or Table 4 = "Capabilities.ID"
when "ResponsePlanList.PrimaryCode" value = 0
PrimaryOrder
SubstituteCode
SubstituteID = "Foreign Key to either Table 3 = "Resource.ID" when
"ResponsePlanList.SubstituteCode" value or = 1 or Table 4 = "Capabilities.ID"
when "ResponsePlanList.SubstituteCode" value = 0
SubstituteTime
AdditionalCode
AdditionalID = "Foreign Key to either Table 3 = "Resource.ID" when
"ResponsePlanList.AdditionalCode value or = 1 or Table 4 = "Capabilities.ID"
when "ResponsePlanList.AdditionalCode value = 0
AdditionalTime
Table 2 "ResponsePlan" fields =
ID
Name
JurisdictionID
AlarmLevel
Group_ID
DispatchLevelID
Active
AutomaticDispatchEnabled
Table 3 = "Resource" fields =
ID
Code
Description
Table 4 = "Capabilities" fields =
ID
Code
Description
The Table 1 "ResponsePlanList" fields, PrimaryCode, SubstituteCode and
AdditionalCode are either 0 which refers to Table 4 "Capabilities.ID" or 1
which refers to Table 3 = "Resource.ID".
My report needs to show:
Table 2 "ResponsePlan" fields; Name, AlarmLevel
AND
Table 1 "ResponsePlanList" fields; PrimaryOrder
AND
WHEN Table 1 "ResponsePlanList.PrimaryCode" = 1
Table 3 = "Resource" fields; ID, Code, Description,
OR
WHEN Table 1 "ResponsePlanList.PrimaryCode" = 0
Table 4 = "Capabilities" fields ID, Code, Description
AND
WHEN Table 1 "ResponsePlanList.SubstituteCode" = 1
Table 3 = "Resource" fields; ID, Code, Description,
OR
WHEN Table 1 "ResponsePlanList.SubstituteCode" = 0
Table 4 = "Capabilities" fields ID, Code, Description
AND "ResponsePlanList.SubstituteTime"
UNLESS "ResponsePlanList.SubstituteID" = -1
AND
WHEN Table 1 "ResponsePlanList.AdditionalCode" = 1
Table 3 = "Resource" fields; ID, Code, Description,
OR
WHEN Table 1 "ResponsePlanList.AdditionalCode" = 0
Table 4 = "Capabilities" fields ID, Code, Description
AND "ResponsePlanList.AdditionalTime"
UNLESS "ResponsePlanList.AdditionalID" = -1
Any help is appreciated, I have been all around this for 2 days straight.