사번 이름 지역 나이 전화번호
-------------------------------------------------------------
101 홍길동 서울 30
101 홍길동 서울 _ 010-1234-5678
102 김철수 대전 26 010-321-7654
102 김철수 대전 26 010-765-1532
102 김철수 대전 26 010-934-2356
103 이영희 부산 _ 010-1234-5678
103 이영희 부산 24
사번 이름 지역 나이 전화번호
--------------------------------------------------
101 홍길동 서울 30 010-1234-5678
102 김철수 대전 26 010-321-7654
102 김철수 대전 26 010-765-1532
102 김철수 대전 26 010-934-2356
103 이영희 부산 24 010-1234-5678
질문내용이 부족해서 다시 질문드립니다. DATA를 아래의 결과로 조회하고싶습니다.
어떻게 조회하는게 좋을까요?
언더라인(_)은 공백이 안들어가서 넣은것입니다.
with t as ( select '101' as no, '홍길동' as name, '서울' as loc, '30' as age, '' as telno from dual union all select '101' as no, '홍길동' as name, '서울' as loc, '' as age, '010-1234-5678' as telno from dual union all select '102' as no, '김철수' as name, '대전' as loc, '26' as age, '010-321-7654' as telno from dual union all select '102' as no, '김철수' as name, '대전' as loc, '26' as age, '010-765-1532' as telno from dual union all select '102' as no, '김철수' as name, '대전' as loc, '26' as age, '010-934-2356' as telno from dual union all select '103' as no, '이영희' as name, '부산' as loc, '' as age, '010-1234-5678' as telno from dual union all select '103' as no, '이영희' as name, '부산' as loc, '24' as age, '' as telno from dual ) select no, name, loc, age, telno from ( select no, name, loc, max(age) as age, max(telno) as telno from t where age is null or telno is null group by no, name, loc union all select no, name, loc, age, telno from t where not (age is null or telno is null) ) order by 1