안녕하세요!
이번 포스팅은 LeetCode에 있는 Article Views I문제를 OracleDB로 풀어보려고 합니다!
(모든 문제는 Oracle로 풀이하겠습니다.)
1. 문제 링크 : https://leetcode.com/problems/article-views-i/description/
2. 문제
| Column name | Type |
| article_id | int |
| author_id | int |
| viewer_id | int |
| view_date | date |
[문제] Write a solution to find all the authors that viewed at least one of their own articles.
Return the result table sorted by id in ascending order.
자신의 기사 중 하나 이상을 본 모든 저자를 조회하는 문제입니다.
3. 제출 쿼리 및 설명
최종) 기사를 쓴 사람(AUTHOR_ID)와 그 기사를 본 사람(VIEWER_ID)가 같은 사람의 아이디를 조회합니다.
SELECT DISTINCT AUTHOR_ID AS ID
FROM VIEWS
WHERE AUTHOR_ID = VIEWER_ID
ORDER BY AUTHOR_ID ASC
;
'SQL > LeetCode' 카테고리의 다른 글
| [SQL] Product Price at a Given Date(LeetCode/Oracle) (0) | 2023.10.19 |
|---|---|
| [SQL] Market Analysis I(LeetCode/Oracle) (1) | 2023.10.19 |
| [SQL] User Activity for the Past 30 Days I(LeetCode/Oracle) (0) | 2023.10.19 |
| [SQL] Sales Analysis III(LeetCode/Oracle) (0) | 2023.10.19 |
| [SQL] Project Employees I(LeetCode/Oracle) (0) | 2023.10.19 |