먼저 아찌님이 말씀하신 방법대로 해보면
with t as ( select 'Y' a, 'N' b, null c from dual union all select 'Y' a, 'N' b, null c from dual union all select 'Y' a, 'N' b, null c from dual union all select 'N' a, 'N' b, 'Y' c from dual ) select to_char(wm_concat(distinct col)) coly from ( select * from ( select * from t ) unpivot ( val for col in (a, b, c))--Y가 들어갈 수 있는 컬럼 나열 ) where val = 'Y'
-- 실제 적용하실 때는 with 문 지우시고
-- 아래 쿼리에서 t 자리에 해당 테이블명 적으시고 해당 컬럼을 unpivot 문에 적으시면 됩니다.
다른 방법으로는..
select to_char(nvl (wm_concat (column_name), 'no data found')) from (select column_name from all_tab_columns where table_name = upper ('테이블명') and to_number (dbms_xmlgen.getxmltype ( 'select 1 from ' || table_name || ' where ' || column_name || ' = ''Y'' and rownum = 1' ).extract ('//text()') ) = 1 order by column_name);
테이블에서 컬럼별로 Y인 값 1개만 찾기 때문에 이게 더 빠를 수도 있을 것 같은데 테스트해보세요.