oracle sql developer 질문드립니다. 0 6 449

by 켠서 [2019.08.21 17:06:21]


안녕하세요..!!

매번 질문을 드리는 것 같아서 송구합니다..

코드는 이렇습니다.

select 
    key_seq as visit_concept_id,
    person_id as person_id,
    case when form_cd in ('02', '04', '06', '07', '10', '12') and in_pat_cors_type in ('11', '21', '31') then 9203 --입원 + 응급
        when form_cd in ('02', '04', '06', '07', '10', '12') and in_pat_cors_type not in ('11', '21', '31') then 9201 --입원 + 입원
        when form_cd in ('03', '05', '08', '09', '11', '13', '20', '21', 'ZZ') and in_pat_cors_type in ('11', '21', '31') then 9203 --외래 + 응급
        when form_cd in ('03', '05', '08', '09', '11', '13', '20', '21', 'ZZ') and in_pat_cors_type not in ('11', '21', '31') then 9202 --외래 + 외래
        else 0
    end as visit_concept_id,
    TO_DATE(recu_fr_dt, 'yyyymmdd') as visit_start_date,
    null as visit_start_time,
    case when form_cd in ('02', '04', '06', '07', '10', '12') then TO_DATE(recu_fr_dt, 'yyyymmdd') + vscn - 1 
        when form_cd in ('03', '05', '08', '09', '11', '13', '20', '21', 'ZZ') and in_pat_cors_type in ('11', '21', '31') then TO_DATE(recu_fr_dt, 'yyyymmdd') + vscn - 1
        else TO_DATE(recu_fr_dt, 'yyyymmdd')
    end as visit_end_date,
    null as to_number(visit_end_time),
    44818517 as visit_type_concept_id,
    null as provider_id,
    ykiho_id as care_site_id,
    key_seq as visit_source_value,
    null as visit_source_concept_id
from cohort_cdm.NHID_20T;

ora - 00923 from 키워드가 필요한 위치에 없다고 하는데용..

44818517 as visit_type_concept_id,이 행이 잘못되었다고 하는데.. 어떻게 바꿔주면 좋을가용??..

by 생각 [2019.08.21 17:56:49]

ALIAS에 함수가 들어가 있네요.


by 마농 [2019.08.21 18:07:10]

null as to_number(visit_end_time)


by 켠서 [2019.08.21 18:25:04]

어디 부분을 바꿔줘야 댄다는거죠?.. 이해를 못했습니다.


by 마농 [2019.08.21 18:32:48]

기본 사용법은 (표현식 AS 별칭) 입니다.
그런데 별칭에 함수를 사용했네요.


by 켠서 [2019.08.23 09:11:06]

그러면 null as to_number(visit_end_time) 이거를 

null as visit_end time, 원래 이런식이라는거죠??


by 켠서 [2019.08.23 09:12:34]

to_number 없애니 바로되네요 감사합니다!!ㅠㅠ

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입