面对下面的查询遇到的一些问题,并寻找使错误无效但无法成功的选项。也许连接不正确,并且查询可能也不是它的最佳优化状态。如果你能帮忙解决这个问题会很高兴:
SELECT DISTINCT
hpd_help_desk.contact_company,
hpd_help_desk.incident_number,
MIN(remedy.chr_imp_impact_main.start_time),
MAX(remedy.chr_imp_impact_main.end_time),
hpd_help_desk.closed_date,
MAX(remedy.chr_imp_impact_main.end_time),
24,
remedy.chr_imp_impact_main.condition,
hpd_help_desk.condition,
hpd_help_desk.severity,
hpd_help_desk.department_of_authority,
hpd_help_desk.self_inflicted,
CASE
WHEN hpd_help_desk.assigned_group LIKE '%NOC%'
OR hpd_help_desk_assignment_log.assigned_group LIKE '%NOC%'
OR hpd_help_desk.owner_group LIKE '%NOC%' THEN 1
ELSE 0
END
FROM remedy.hpd_help_desk
INNER JOIN remedy.hpd_help_desk_assignment_log
ON (
hpd_help_desk.incident_number = hpd_help_desk_assignment_log.incident_number
)
LEFT OUTER JOIN remedy.chr_imp_impact_main
ON (
hpd_help_desk.incident_number = chr_imp_impact_main.sourcerequestid
)
WHERE (
CASE
WHEN hpd_help_desk.assigned_group LIKE '%NOC%'
OR hpd_help_desk_assignment_log.assigned_group LIKE '%NOC%'
OR hpd_help_desk.owner_group LIKE '%NOC%' THEN 1
ELSE 0
END = 1
AND CASE
WHEN hpd_help_desk.self_inflicted IN ('0', '2')--ENUMID for Yes & Under Review are 0 & 2 resp
AND hpd_help_desk.condition = '1' --ENUMID for Impairment = 1
OR hpd_help_desk.condition = '0' THEN 1 --ENUMID for Outage = 0
ELSE 0
END = 1
)
GROUP BY
hpd_help_desk.contact_company,
hpd_help_desk.condition,
hpd_help_desk.self_inflicted,
hpd_help_desk.incident_number,
chr_imp_impact_main.condition,
hpd_help_desk.closed_date,
hpd_help_desk.severity,
hpd_help_desk.department_of_authority,
CASE
WHEN hpd_help_desk.assigned_group LIKE '%NOC%'
OR hdp_help_desk_assignment_log.assigned_group LIKE '%NOC%'
OR hpd_help_desk.owner_group LIKE '%NOC%' THEN 1
ELSE 0
END'
我收到错误:
ERROR: missing FROM-clause entry for table "hdp_help_desk_assignment_log"
将Postgres作为我们的数据库。任何建议都将受到高度赞赏!