* union all 활용해서 두 테이블을 합친 with절 테이블을 생성
with tbn as
(
select requester_id as id from RequestAccepted
union all
select accepter_id as id from RequestAccepted
)
select id, count(*) as num from tbn
group by id
order by num desc
limit 1
'Data > SQL' 카테고리의 다른 글
[Leetcode] 175. Combine Two Tables, 178. Rank Scores, 184. Department Highest Salary (0) | 2024.01.15 |
---|---|
[Leetcode] 1661. Average Time of Process per Machine (0) | 2024.01.09 |
[Leetcode] 1757. Recyclable and Low Fat Products (0) | 2024.01.08 |
[프로그래머스] 가격대 별 상품 개수 구하기 (0) | 2024.01.07 |
[프로그래머스] 상품을 구매한 회원 비율 구하기 (0) | 2024.01.06 |