我有一张表来显示目标和完成时间,所有信息都来自一个表“ job”-但是我现在想添加更多的SQL以提供另一个表“ job_type”中的信息,但是只要我保持得到错误消息说 “ SQLSTATE = S0022 [Oracle] [ODBC] [ORA] ORA-00904:“ JOB_TYPE”。“ JOB_TYPE_CODE”:无效的标识符。
我拥有的有效代码(无需添加任何内容)
select
job_number, priority_code, job_entry_date, clock_start,
site_code,
TO_CHAR(job_entry_date, 'Dy') as DAY_LOGGED,
TO_CHAR(actual_start_date, 'IW') as WEEK_ON_SITE,
actual_start_date,
actual_comp_date,
-- kpi tracker
CASE
WHEN actual_start_date is null AND current_date < target_time THEN 'Not arrived on site yet'
WHEN actual_start_date is null AND current_date > target_time THEN 'FAIL (2)'
when actual_start_date <= target_time then 'Pass'
when actual_start_date > target_time then 'FAIL'
ELSE 'Overdue' END as Arrived_on_time_check,
-- start of correct target time SQL
case
when to_char(target_time, 'Dy', 'NLS_DATE_LANGUAGE=ENGLISH') = 'Fri'
and floor((target_time - trunc(target_time)) * 24) >= 17
then target_time + 2 + 63/24
when floor((target_time - trunc(target_time)) * 24) >= 17
then target_time + 15/24
else target_time
end as target_time
from
(
select job_number, priority_code, job_entry_date, clock_start, site_code, actual_start_date, actual_comp_date,
CASE
WHEN PRIORITY_CODE IN ('GC01','GC02','GC03','GC04','GC05','GC06','GC07')
THEN
clock_start + case priority_code
when 'GC01' then 1
when 'GC02' then 2
when 'GC03' then 0.5
when 'GC04' then 1
when 'GC05' then 2
when 'GC06' then 4
when 'GC07' then 24
end / 24
ELSE TARGET_COMP_DATE END as target_time
from
(
select job_number, priority_code, job_entry_date, target_comp_date, site_code, actual_start_date, actual_comp_date,
case
when to_char(job_entry_date, 'Dy', 'NLS_DATE_LANGUAGE=ENGLISH') = 'Fri'
and floor((job_entry_date - trunc(job_entry_date)) * 24) >= 17
then trunc(job_entry_date) + 80/24
when to_char(job_entry_date, 'Dy', 'NLS_DATE_LANGUAGE=ENGLISH') = 'Sat'
then trunc(job_entry_date) + 56/24
when to_char(job_entry_date, 'Dy', 'NLS_DATE_LANGUAGE=ENGLISH') = 'Sun'
or floor((job_entry_date - trunc(job_entry_date)) * 24) >= 17
then trunc(job_entry_date) + 32/24
when floor((job_entry_date - trunc(job_entry_date)) * 24) < 8
then trunc(job_entry_date) + 8/24
else job_entry_date
end as clock_start
from job
)
)
where
priority_code in ('GC01','GC02','GC03','GC04','GC05','GC06','GC07')
我要添加的代码是:
-- JOB KPI ATTRIBUTE LOOK UP IN GJOB TABLE
(SELECT attribute_value.attrib_value_name FROM attribute_value WHERE
attribute_value.attrib_type_code = 'GJOB'
AND attribute_value.attrib_value_code = job_type.job_type_code) as JOB_KPI,
-- JOB KPI PENALTY POINTS LOOK UP IN GJOB TABLE
(SELECT attribute_value.attrib_value_nom FROM attribute_value WHERE
attribute_value.attrib_type_code = 'GJOB'
AND attribute_value.attrib_value_code = job_type.job_type_code) as KPI_POINTS,
如何将以上代码添加到现有代码中,而不会出现错误消息,指出它是无效的标识符?