select regyear,((select maechul from operationSmt where id='6218144750' and regyear=(select max(regyear)-2 from operationSmt) as danggi_maedchul/CASE WHEN (select maechul from operationSmt where id='6218144750' and regyear=(select max(regyear)-3 from operationSmt)) IS_NULL THEN 1 ELSE (select maechul from operationSmt where id='6218144750' and regyear=(select max(regyear)-3 from operationSmt)) END AS jeonggi_maechul))*100-100 as maechul from operationSmt where id = '6218144750' and regyear = (select max(regyear)-2 from operationSmt)
CASE WHEN (select maechul from operationSmt where id='6218144750' and regyear=(select max(regyear)-3 from operationSmt)) IS_NULL THEN 1 ELSE (select maechul from operationSmt where id='6218144750' and regyear=(select max(regyear)-3 from operationSmt)) END AS jeonggi_maechul))
이부분에서 오류가 발행하는데요... null값일 경우 1을 아닐경우는 값을 나타내려합니다.
어떻게 하면 될까요?
Comment 1
-
건우아빠
2017.01.16 14:16
쿼리를 정리 하시고 질문을 하시는게 좋을듯 합니다.
서브쿼리보다는 그 부분을 함수화 하시면 좀 쿼리의 가독성이 높아 질듯 합니다.
넘 복잡해서 보기가 힘듭니다.
테이블의 기본 샘플 자료도 같이 올려 주시는게 좋습니다.