오라클 버전은 11g입니다.
제가 쿼리를 잘 모르는건지 해서 답답해서 문의 드립니다.
SELECT '' AS CHK,
COL1,
COL2,
COL3
FROM (
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL UNION ALL
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL UNION ALL
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL UNION ALL
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL UNION ALL
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL UNION ALL
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL UNION ALL
SELECT '1' AS COL1, '2' AS COL2, '3' AS COL3 FROM DUAL
)
GROUP BY COL1,
COL2;
GROUP BY 절에 COL3을 뺄 경우 당연히 오류가 납니다. COL3이 없다고요...
SELECT '1' AS CHK
,CODE_SEQ
,CODE_CD
FROM (
SELECT 1 AS CODE_SEQ
,'1' AS CODE_CD
FROM tb_CODE A /*일반 테이블에다가 그냥 상수값만 적용시킴*/
)
GROUP BY CODE_SEQ;
GROUP BY 절에 CODE_CD가 포함되어 있지 않습니다. 그런데 쿼리 실행시 오류 없이 진행 됩니다.
같은 쿼리지만 아래의 쿼리에서 CHK칼럼을 뺄 경우 오류가 발생합니다.
SELECT
CODE_SEQ
,CODE_CD
FROM (
SELECT 1 AS CODE_SEQ
,'1' AS CODE_CD
FROM tb_CODE A /* 일반 테이블에다가 그냥 상수값만 적용시킴*/
)
GROUP BY CODE_SEQ;
|