我有以下疑问:
select
PatientId,
EncounterId,
dead,
encounterEndTime,
max_Hr,
min_Hr,
mean_Hr
from((select SUBSTR(get_json_object(content,'$.patient.reference'),9) as PatientId,
get_json_object(content,'$.id') as EncounterId,(case
when get_json_object(content,'$.reason.coding.display') like '%Dead%' then "1"
else "0" end ) as dead, regexp_replace((get_json_object(content,'$.period.end')),"T"," ") as encounterEndTime from encounter_sample
where get_json_object(content,'$.patient.reference') like '%Patient/%' and get_json_object(content,'$.serviceProvider.reference') like '%Organization/6f5dd7a5-f643-4309-8602-8200c6c43893%' and get_json_object(content,'$.status') like 'finished')enc
LEFT OUTER JOIN
(select SUBSTR(get_json_object(content,'$.subject.reference'),9) as PatientIdHr,
max(cast (get_json_object(content,'$.component[0].valueQuantity.value')as int))as max_Hr,
min(cast (get_json_object(content,'$.component[0].valueQuantity.value') as int))as min_Hr,
round(avg(cast (get_json_object(content,'$.component[0].valueQuantity.value') as int)),2) as mean_Hr,
SUBSTR(get_json_object(content,'$.encounter.reference'),11) as EncounterIdHR
from production.observation_sample
where get_json_object(content,'$.meta.tag[0].code') like 'cm_vitalsigns_result%' and get_json_object(content,'$.component[0].code.coding[0].display') like 'Heart Rate (per minute)' and regexp_replace((get_json_object(content,'$.effectiveDateTime')),"T"," ") > from_unixtime(unix_timestamp(enc.encounterEndTime)-14400)
group by (get_json_object(content,'$.component[0].code.coding[0].display')),(SUBSTR(get_json_object(content,'$.subject.reference'),9)),SUBSTR(get_json_object(content,'$.encounter.reference'),11))Hr
on
PatientId=PatientIdHr and EncounterId=EncounterIdHR)
上面说 enc.encounterEndTime
无法使用,并出现如下错误:配置单元失败语义分析中的错误无效表别名或列引用。我应如何继续。
1条答案
按热度按时间a2mppw5e1#
不能引用为左联接子查询中的另一个子查询定义的表别名。
因为它是外连接,所以您可能希望它沿着
ON
条款?