반응형
https://leetcode.com/problems/find-followers-count/description/
group by를 사용해본 문제였습니다.
📕 풀이방법
📔 풀이과정
user_id에 대해 group by한 후 user_id와 follwer_id의 countr값을 projection 후 select해줍니다.
📕 Code
📔 ANSI sql
select user_id, count(follower_id) as followers_count
from followers
group by user_id
order by user_id
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'SQL' 카테고리의 다른 글
(SQL) - LeetCode (easy) 1757. Recyclable and Low Fat Products (0) | 2024.07.18 |
---|---|
(SQL) - LeetCode (easy) 1741. Find Total Time Spent by Each Employee (0) | 2024.07.10 |
(SQL) - LeetCode (easy) 1693. Daily Leads and Partners (0) | 2024.06.13 |
(SQL) - LeetCode (easy) 1683. Invalid Tweets (0) | 2024.06.07 |
(SQL) - LeetCode (easy) 1667. Fix Names in a Table (0) | 2024.05.30 |