https://school.programmers.co.kr/learn/courses/30/lessons/164670
정답
SELECT
USER_ID
, NICKNAME
, (CITY || ' ' || STREET_ADDRESS1 || ' ' || STREET_ADDRESS2) AS 전체주소
, CASE WHEN LENGTH(TLNO) = 11 THEN SUBSTR(TLNO,0,3) || '-' || SUBSTR(TLNO,4,4) || '-' || SUBSTR(TLNO,8,4)
END AS 전화번호
FROM USED_GOODS_USER
WHERE USER_ID IN (
SELECT
B.USER_ID
FROM USED_GOODS_BOARD A, USED_GOODS_USER B
WHERE A.WRITER_ID = B.USER_ID
GROUP BY B.USER_ID
HAVING COUNT(*) >=3
)
ORDER BY USER_ID DESC;
풀이
Step1) 서브쿼리
SELECT B.USER_ID
FROM USED_GOODS_BOARD A, USED_GOODS_USER B
WHERE A.WRITER_ID = B.USER_ID
GROUP BY B.USER_ID
HAVING COUNT(*) >=3
Step 2) In 연산자
https://lavender1122.tistory.com/324
Step 3) select 절 문자열 결합
https://lavender1122.tistory.com/323
'DB > 오라클' 카테고리의 다른 글
[Oracle] MERGE (3) | 2024.10.16 |
---|---|
[Oracle] 오라클 WITH 절 사용법 및 동작 방식 (0) | 2024.10.13 |
[Oracle] SQL 서브쿼리 SELECT,FROM,WHERE (0) | 2024.09.23 |
[Oracle] 문자열 합치는 방법(||, CONCAT()) (0) | 2024.09.23 |
[ORACLE] INSTR() 함수: 문자 찾기 (0) | 2024.09.09 |