WITH t AS ( SELECT 'A' PLACE, '흑점' ERROR_NAME, 189 ERROR_COUNT FROM DUAL UNION ALL SELECT 'B' PLACE, '흑점' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'A' PLACE, '합판(박리)불량' ERROR_NAME, 593 ERROR_COUNT FROM DUAL UNION ALL SELECT 'B' PLACE, '합판(박리)불량' ERROR_NAME, 2 ERROR_COUNT FROM DUAL UNION ALL SELECT 'C' PLACE, '합판(박리)불량' ERROR_NAME, 15 ERROR_COUNT FROM DUAL UNION ALL SELECT 'D' PLACE, '합판(박리)불량' ERROR_NAME, 10 ERROR_COUNT FROM DUAL UNION ALL SELECT 'A' PLACE, '터짐/취급' ERROR_NAME, 2753 ERROR_COUNT FROM DUAL UNION ALL SELECT 'B' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'C' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'D' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'E' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL ) 위 자료가 아래처럼 정렬되도록 쿼리 작성 부탁드립니다.
설명이 부족했나봅니다
ERROR_COUNT가 큰 값의 ERROR_NAME 전체가 정렬되는 내용입니다. PLACE는 참조만 하시면되고 정렬과는 무관합니다.
A 터짐/취급 2753
B 터짐/취급 0
C 터짐/취급 0
D 터짐/취급 0
E 터짐/취급 0
A 합판(박리)불량 593
C 합판(박리)불량 15
D 합판(박리)불량 10
B 합판(박리)불량 2
A 흑점 189
B 흑점 0
이리저리 머리를 굴려도 모르겠네요 휴~~~~
WITH t AS ( SELECT 'A' PLACE, '흑점' ERROR_NAME, 189 ERROR_COUNT FROM DUAL UNION ALL SELECT 'B' PLACE, '흑점' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'A' PLACE, '합판(박리)불량' ERROR_NAME, 593 ERROR_COUNT FROM DUAL UNION ALL SELECT 'B' PLACE, '합판(박리)불량' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'C' PLACE, '합판(박리)불량' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'D' PLACE, '합판(박리)불량' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'A' PLACE, '터짐/취급' ERROR_NAME, 2753 ERROR_COUNT FROM DUAL UNION ALL SELECT 'B' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'C' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'D' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL UNION ALL SELECT 'E' PLACE, '터짐/취급' ERROR_NAME, 0 ERROR_COUNT FROM DUAL ) SELECT * FROM t ORDER BY ERROR_NAME, PLACE --, ERROR_COUNT DESC ; 아앗 답변이 달린 뒤 예시 기준이 더 추가 됬군요..ㅎㅎ