在将以下Taradata中的SQL查询转换为Oracle exadata时,我需要帮助。不知道如何转换日期,我更改了CAST日期函数To_Date,但遇到了一些错误。
SELECT DISTINCT
pat.pat_id,
pat.pat_mrn_id AS patientmrn,
pat.pat_name AS patientname,
adt_pat_class_c,
pat.death_date AS deathdate,
cast(patenc.hosp_admsn_time AS DATE format 'mm/dd/yyyy') AS
admitdate,
cast(patenc.hosp_disch_time AS DATE format 'mm/dd/yyyy') AS
dischargedate,
extract(year FROM acct.adm_date_time)-extract(year FROM
pat.birth_date) - CASE WHEN acct.adm_date_time (format
'MMDD')CHAR(4))
<pat.birth_date (format 'MMDD') (CHAR(4)) THEN 1 ELSE 0
END AS patage,
adt_billing_type_c,
adt_patient_stat_c,
hosp_admsn_type_c,
acct_basecls_ha_c,
ordproc.order_proc_id AS order_id,
ordproc.ordering_date
FROM patient pat
inner join pat_enc_hsp patenc ON pat.pat_id = patenc.pat_id
inner join hsp_account acct ON acct.prim_enc_csn_id = patenc.pat_enc_csn_id
inner join order_proc ordproc ON acct.prim_enc_csn_id ON
ordproc.pat_enc_csn_id
inner join clarity_ser ser ON ser.prov_id = ordproc.authrzing_prov_id
inner join identity_ser_id idser ON ser.prov_id=idser.prov_id
inner join clarity_loc loc ON loc.loc_id = acct.loc_id
inner join zc_loc_rpt_grp_7 grp7 ON loc.rpt_grp_seven = grp7.rpt_grp_seven
WHERE grp7.name = 'AB'
AND cast(patenc.hosp_disch_time AS DATE format 'mm/dd/yyyy') >= '01/01/2019'
AND admit_conf_stat_c IN (1,4)
AND description LIKE '%CULTURE%'
AND ordproc.lab_status_c = 3
AND adt_pat_class_c IN ('1204','12113')
AND result_time > patenc.hosp_disch_time;
我更改了查询的顶部(一个带日期)-
select distinct
pat.pat_id,
pat.PAT_MRN_ID as PatientMRN,
pat.PAT_NAME as PatientName,
ADT_PAT_CLASS_C,
pat.DEATH_DATE as DeathDate,
TO_DATE(patenc.HOSP_ADMSN_TIME, 'mm/dd/yyyy') as AdmitDate,
TO_DATE(patenc.HOSP_DISCH_TIME, 'mm/dd/yyyy') as DischargeDate----
我收到以下错误- ORA-12801:在并行查询服务器P02G中发出错误信号,实例nzcladb01xm.nndc.kp.org:CDB001N41(1) ORA-01843:无效月份 12801。00000-“在并行查询服务器%s中发出错误信号” *原因:并行查询服务器达到异常条件。 *操作:检查以下错误消息以查找原因,然后咨询 您的错误手册,以采取适当的措施。 *评论:可以通过事件10397来关闭此错误,其中 而是指示服务器的实际错误。