在datawarehouse脚本中获取Parse错误

时间:2018-06-12 07:50:24

标签: azure azure-sqldw

我在下面的脚本中收到错误,它在某处附近有一个解析错误,我不知道错误是什么,可以告诉我什么是错误的判断,内部选择distinct命令运行正常但是外部不同的声明没有跑。

INSERT INTO ccsm.trn_custom_cohorts (person_id, encounter_id, cohort_type, cohort, cohort_val, ts_cohort, dt_create, optional1, optional2)
  SELECT DISTINCT
    person_id,
    encounter_id,
    cohort_type,
    cohort,
    cohort_val,
    cast(ts_cohort AS date),
    sysdate           AS dt_create,
    median            AS optional1,
    jvion_cohort_type as optional2
  from
    (SELECT distinct
       xx_person_id                                                                                   AS person_id,
       xx_encounter_id                                                                                AS encounter_id,
       'Vitals'                                                                                       AS cohort_type,
       mod_optional1                                                                                  AS cohort,
       vital_sign                                                                                     AS cohort_val,
       ISNULL(cast(assessment_time as date), cast(mod_optional_ts1 as date))                   AS ts_cohort,
       'Vitals'                                                                                       as jvion_cohort_type,
       rank()
       OVER (
         PARTITION BY account_identifier, mod_optional1
         ORDER BY ISNULL(cast(assessment_time as date), cast(mod_optional_ts1 as date)) DESC ) AS rank1,
         null                              AS median
     FROM ccsm.stg_vital_signs
     WHERE vital_sign <> '')
  where rank1 = 1;

1 个答案:

答案 0 :(得分:0)

你没有别名你的子查询。

WHERE vital_sign <> '') MY_ALIAS