SQL/리트코드 문제풀이

1148. Article Views I

너지살 2024. 4. 30. 16:58

 

 

 

문제 출저

https://leetcode.com/problems/article-views-i/description/?envType=study-plan-v2&envId=top-sql-50

 

 

 

문제 풀이

자신의 작품을 본 작가 id를 출력해야 합니다 where 사용하여 author_id와 viewer_id 같은 것을 선택합니다. 중복을 제거하기 위해 distinct를 사용합니다. order by로 id를 정렬합니다.

 

 

SQL

select 
    distinct author_id
    as id
from
    Views
where
    author_id = viewer_id
order by
    id