我正在"当我尝试运行以下查询时,列模糊定义" 错误:
SELECT ROWNUM, sub.* FROM
(SELECT orm.msg_id,
--Facility
msh.sending_corp as source_system,
msh.sending_corp,
msh.sending_facility,
fsub.east_west_flag,
fsub.account_number,
fsub.HLAB_NUM,
fsub.cid,
fsub.facility_id,
--Patient
pid.EXT_PAT_ID,
pid.patient_name,
pid.ssn,
pid.sex,
pid.date_of_birth,
pat.spectra_mrn,
pat.patient_id,
pv1.attending_doctor,
--Order
orc.order_control,
orc.EXT_ORDER_ID,
orc.draw_date,
lab.LAB_ORDER_OCC_ID,
pv1.modality,
lab.MSG_SENT_TO_LAB_YN as order_transmit_status,
xref.REQUISITION_NO,
lab_test.DRAW_DT as src_draw_date,
xref.REQUISITION_NO as src_req_number,
--Test
lab_test.LAB_ORDER_OCC_ID as order_id_of_ordertest_tbl,
lab_test.LAB_ORDER_OCC_TEST_ID,
emr.emr_order_number as emr_test_order_id_ordtst_tbl,
lab_test.TEST_SENT_TO_LAB_YN as test_transmit_status,
SUBSTR(obr.EXT_TEST_ORDER_ID, 1, DECODE(INSTR(obr.EXT_TEST_ORDER_ID,'-',1,1),0,LENGTH(obr.EXT_TEST_ORDER_ID),INSTR(obr.EXT_TEST_ORDER_ID,'-',1,1)-1)) EXT_TEST_ORDER_ID,
obr.test_details,
--obr.priority,
SUBSTR(obr.collection_time,1,4) as collection_time,
NVL(src.internal_code, obr.specimen_source) as specimen_source,
NVL2(lab_test.LAB_ORDER_OCC_TEST_ID,tst.SPECIMEN_TYPE,SUBSTR(tst.container, 1, INSTR(tst.container,'|',1,1)-1) || '^' || SUBSTR(tst.container, INSTR(tst.container, '|',-1,1)+1)) AS collector_identifier,
obr.EXT_TEST_DETAILS,
obr.frequency,
NVL2(lab_test.LAB_ORDER_OCC_TEST_ID,tst.test_code,tst.test_code) AS test_code,
NVL2(lab_test.LAB_ORDER_OCC_TEST_ID,tst.test_name,tst.test_name) AS test_name,
NVL2(lab_test.LAB_ORDER_OCC_TEST_ID,tst.test_id,tst.test_id) AS test_id,
obr.sl_no,
xref.ACCESSION_NO,
tst.order_flag,
obr.ORDERING_DOCTOR,
DECODE(INSTR(obr.EXT_TEST_ORDER_ID,'-',1,1),0,NULL,SUBSTR(obr.EXT_TEST_ORDER_ID, INSTR(obr.EXT_TEST_ORDER_ID,'-',1,1)+ 1)) as reschedule_count,
--Diag
lab_test_dg.LAB_ORDER_OCC_TEST_ID,
dg1.diagnosis_code,
icd.ICD9_CODE,
icd.ICD9_CODE_ID,
icd.description,
dg1.diagnosis_coding_method,
dg1.obr_sl_no
FROM INT_RCV_ORM orm
--Facility
INNER JOIN INT_RCV_ORM_MSH msh ON orm.MSG_ID = msh.msg_id
LEFT OUTER JOIN
(SELECT * FROM (
(SELECT rank() OVER (PARTITION BY fac.facility_id ORDER BY DECODE(fad.ACCOUNT_TYPE,'NA','ZZZ',fad.ACCOUNT_TYPE)) RNK,
fad.* FROM facility fac ,Facility_Account_Detail fad WHERE
fac.facility_id = fad.facility_id and
UPPER(fac.facility_status) IN ('A')
AND UPPER(fad.ACCOUNT_TYPE) NOT IN ('STAFF','WATER')))
WHERE RNK = 1
)fsub
ON fsub.facility_id = msh.sending_facility
--Patient
INNER JOIN INT_RCV_ORM_PID pid ON orm.msg_id = pid.msg_id
LEFT OUTER JOIN patient pat ON pid.EXT_PAT_ID = pat.EXTERNAL_ID
INNER JOIN INT_RCV_ORM_PV1 pv1 ON orm.msg_id = pv1.msg_id
--Orders
INNER JOIN INT_RCV_ORM_ORC orc ON orm.msg_id = orc.msg_id
LEFT OUTER JOIN EMR_LAB_ORDER_DTL emr ON emr.emr_order_number = orc.EXT_ORDER_ID
left outer join LAB_ORDER_OCC lab on lab.LAB_ORDER_OCC_ID= emr.LAB_ORDER_OCC_ID
left outer join ORDER_OCC_REQUISITION_X_REF xref on xref.LAB_ORDER_OCC_ID=lab.LAB_ORDER_OCC_ID
--Order Test
INNER JOIN INT_RCV_ORM_OBR obr ON orm.msg_id = obr.msg_id
left outer join LAB_ORDER_OCC_TEST lab_test on lab_test.LAB_ORDER_OCC_ID = xref.LAB_ORDER_OCC_ID
AND emr.emr_order_number = SUBSTR(obr.EXT_TEST_ORDER_ID, 1, DECODE(INSTR(obr.EXT_TEST_ORDER_ID,'-',1,1),0,LENGTH(obr.EXT_TEST_ORDER_ID),INSTR(obr.EXT_TEST_ORDER_ID,'-',1,1)-1)) AND lab_test.draw_dt = TO_DATE(orc.draw_date,'YYYYMMDD')
LEFT OUTER JOIN test tst ON tst.test_code = SUBSTR(obr.test_details,1,INSTR(obr.test_details,'^',1,1)-1) AND NVL(tst.inactive_date,TRUNC(SYSDATE)) >= TRUNC(SYSDATE) AND tst.orderable_yn = 'Y' AND (tst.test_flag LIKE '%P%' OR tst.test_flag LIKE '%T%')
LEFT OUTER JOIN source src ON src.source_name = obr.specimen_source AND src.test_id = tst.test_id
--Order Test Diag
LEFT OUTER JOIN INT_RCV_ORM_DG1 dg1 ON orm.msg_id = dg1.msg_id AND dg1.obr_sl_no = obr.sl_no
left outer join LAB_ORDER_OCC_TEST_DIAG lab_test_dg on lab_test_dg.LAB_ORDER_OCC_TEST_ID = lab_test.LAB_ORDER_OCC_TEST_ID
LEFT OUTER JOIN ICD9_CODE icd ON icd.ICD9_CODE = dg1.diagnosis_code
WHERE orm.msg_id BETWEEN in_start_batch_id AND in_end_batch_id
AND orm.msg_id NOT IN (SELECT msg_id FROM GTT_ERROR_RCV_LOG)
AND orm.PROCESSING_STATUS != 'E'
ORDER BY msg_id) sub
LOG ERRORS INTO ERR$_GTT_RCV_ORDER ('RCV_INSERT_GTT_ERROR') REJECT LIMIT UNLIMITED;
查询是在填充临时表的过程中。请提出建议。 我正在
列模糊定义
答案 0 :(得分:0)
如果在任何子句中使用JOIN
和没有别名的列,则会发生此错误。
请重新检查查询。 我的怀疑:
WHERE orm.msg_id BETWEEN `in_start_batch_id` AND `in_end_batch_id`
AND orm.msg_id NOT IN (SELECT msg_id FROM GTT_ERROR_RCV_LOG)
AND orm.PROCESSING_STATUS != 'E'
ORDER BY `msg_id`
如果没有数据模型,这个问题就很难解决。
答案 1 :(得分:0)
存在问题
import json
import pandas as pd
line="json_str"
json_st = json.loads(line)
country=[]
political=[]
address_fields = {
'intersection': [],
'political': [],
'country': []
}
for json_str in json_st:
address_fields = {
'intersection': [],
'political': [],
'country': []
}
if isinstance(json_st,dict):
first_address_components = json_st['results']
#format_add = json_st['results'][0]
else:
first_address_components = json_st[0]['address_components']
for item in first_address_components:
for field_key in address_fields.keys():
#address_fields[field_key].append( str(format_add['formatted_address']))
if field_key in item['types']:
address_fields[field_key].append(item['long_name'])
address_fields = {key: ', '.join(values) for key, values in address_fields.items()}
country.append(address_fields['country'])
political.append(address_fields['political'])
msg_id是我可以看到的几个表上的字段。它不知道使用哪一个。