WITH t AS
(
SELECT 1 no, 'X^O^X^X^X' v FROM dual
UNION ALL SELECT 2, 'X^O^X^O^O' FROM dual
UNION ALL SELECT 3, 'O^O^X^O^O' FROM dual
)
SELECT COUNT(DECODE(SUBSTR(v, 1, 1), 'O', 1))
||'^'|| COUNT(DECODE(SUBSTR(v, 3, 1), 'O', 1))
||'^'|| COUNT(DECODE(SUBSTR(v, 5, 1), 'O', 1))
||'^'|| COUNT(DECODE(SUBSTR(v, 7, 1), 'O', 1))
||'^'|| COUNT(DECODE(SUBSTR(v, 9, 1), 'O', 1)) output
FROM t
;
by 知音
[2011.05.03 15:38:35]
with t as (
select 1 cd, 'X^0^X^X^X' ans from dual union all
select 2, 'X^0^X^0^0' from dual union all
select 3, '0^0^X^0^0' from dual
)
select count(case when substr(ans, 1,1) = '0' then 1 end) || '^' ||
count(case when substr(ans, 3,1) = '0' then 1 end) || '^' ||
count(case when substr(ans, 5,1) = '0' then 1 end) || '^' ||
count(case when substr(ans, 7,1) = '0' then 1 end) || '^' ||
count(case when substr(ans, 9,1) = '0' then 1 end)
from t
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.