select a , b, c from ss
여기서 a 값이 15 나왔습니다.
union all
select a1 , b1, c1 from ss
이렇게 결합했더니
15 나오는 값이 - 이렇게 나옵니다 ..
이건 왜 그런가요
타입 때문인가요?
형변환을 해줘야 하는것인가요??
null 값 때문입니다.
value로 null값을 ''나 0으로 바꿔주세요
select 'A' from sysibm.sysdummy1 union all select cast(null as char) from sysibm.sysdummy1
1
-
A
select 'A' from sysibm.sysdummy1 union all select value(cast(null as char),'') from sysibm.sysdummy1
-- 님 답변 감사 합니다.. 그런데 제가 초보라 지금 쓰신 내용이 이해가 가지 않네요.. sysibm.sysdummy1 널 관련된 값이 있어서 COALESCE(A, 0) 이런형식으로 수정 했는데도 값을 받지 않습니다. 해당 퀘리문은 SELECT DZVA6ODNO ODNO, 'N' BHGB, -1 SEQN, DZVA6DLDT DLDT, DZVA6PTNO PTNO, 0 TIME_, DZVA6PLNT PLNT, DZVA6GTNO GTNO, DZVA6OQTY OQTY, 0 VQTY, (SELECT PE3H05 FROM PRDLIB.PEE3HC WHERE PE3H04 = DZVA6PTNO) ALC, ( SELECT SUM(D401SHIPQ) FROM MTRLIB.dz401dat WHERE D401ORDRNO=DZVA6ODNO ) RCTAG, COALESCE(B.DZVA0QPCS,0) QPCS , DZVA6CRDX CRDX,DZVA6DLTM DLTM,DZVA0PTNM PTNM, DZVA0CSNO CSNO, DZVA0ISDT ISDT FROM MTRLIB.DZVA6P A INNER JOIN MTRLIB.DZVA0P B ON A.DZVA6PLNT = B.DZVA0PLNT AND A.DZVA6VEND = B.DZVA0VEND AND A.DZVA6PTNO = B.DZVA0PTNO WHERE DZVA6VEND = 'BT23' AND DZVA6PLNT > ' ' AND 1=2 AND DZVA6DLDT >= 20071210 AND DZVA6DLDT <= 20071228 AND DZVA6ODNO NOT IN ( SELECT DZVA8ODNO FROM MTRLIB.DZVA8L01) AND DZVA6ODNO NOT IN ( SELECT DZSIKODNO FROM MTRLIB.DZSIKL01) AND DZVA6OQTY > 0 UNION ALL SELECT ODNO, BHGB, SEQN, DLDT, PTNO, TIME_, PLNT, GTNO, OQTY, VQTY, (SELECT PE3H05 FROM PRDLIB.PEE3HC WHERE PE3H04 = PTNO) ALC , QPCS, ( SELECT SUM(D401SHIPQ) FROM MTRLIB.dz401dat WHERE D401ORDRNO=VC.ODNO ) RCTAG, CRDX, DLTM, PTNM, CSNO, ISDT from ( SELECT DZSIKODNO ODNO, 'Y' BHGB, DZSIKSEQN SEQN, DZSIKODDT DLDT, DZSIKPTNO PTNO, DZSIKSTMM TIME_, DZSIKPLNT PLNT, DZSIKGTNO GTNO, DZSIKOQTY OQTY, DZSIKVQTY VQTY, COALESCE(D.DZVA0QPCS,0) QPCS , DZSIKCRDX CRDX, (SELECT DZVA6DLTM FROM MTRLIB.DZVA6P where DZVA6VEND = DZVA0VEND and DZSIKODNO = DZVA6ODNO ) DLTM ,DZVA0PTNM PTNM, DZVA0CSNO CSNO, DZVA0ISDT ISDT FROM MTRLIB.DZSIKP C INNER JOIN MTRLIB.DZVA0P D ON C.DZSIKVEND = D.DZVA0VEND AND C.DZSIKPLNT = D.DZVA0PLNT AND C.DZSIKPTNO = D.DZVA0PTNO WHERE C.DZSIKVEND = 'BT23' AND DZSIKODDT >= 20071210 AND DZSIKODDT <= 20071228 ) VC ORDER BY DLDT DESC, ODNO ASC 이렇게 되어 있고요... 그중에 갯수 관련 필드는 DZVA0QPCS 이 값입니다 어떻게 해야 되나요