프로그래밍연습/SQL
[SQL]조건에 맞는 사용자 정보 조회하기
Q_jihe
2023. 8. 14. 11:25
https://school.programmers.co.kr/learn/courses/30/lessons/164670
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
-- 코드를 입력하세요
with base as (
select
a.user_id
, count(distinct b.board_id) cnt
from USED_GOODS_USER a
join USED_GOODS_BOARD b on a.user_id = b.writer_id
group by 1
)
SELECT
distinct a.user_id
, a.NICKNAME
, concat(a.city,' ', a.street_address1, ' ', a.street_address2) '전체주소'
, concat(substring(a.tlno,1,3), '-', substring(a.tlno,4,4), '-', substring(a.tlno,8,4)) as '전화번호'
from USED_GOODS_USER a
join base b on a.user_id = b.user_id
and b.cnt >= 3
order by 1 desc