[퀴즈] IP 목록 정렬하기
다음과 같이 IP 테이블을 정렬하는 쿼리를 작성하세요.
WITH t AS
(
SELECT '10.100.10.1' ip FROM dual
UNION ALL SELECT '10.100.1.10' FROM dual
UNION ALL SELECT '100.10.1.10' FROM dual
UNION ALL SELECT '100.10.1.20' FROM dual
UNION ALL SELECT '2.10.1.140' FROM dual
)
SELECT ROWNUM rn, ip FROM t;
[원본]
[결과]
RN
IP
RN
IP
1
10.100.10.1
5
002.010.001.140
2
10.100.1.10
2
010.100.001.010
3
100.10.1.10
1
010.100.010.001
4
100.10.1.20
3
100.010.001.010
5
2.10.1.140
4
100.010.001.020
[정답보기] <== 트리플클릭
SELECT ROWNUM rn
, REGEXP_REPLACE(REPLACE('.'||ip, '.', '.00'), '([^.]{3}(\.|$))|.', '\1') ip
FROM t
ORDER BY ip
;