๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SQL/LeetCode

[LeetCode][SQL50] #4. Article Views I

by ์ด๋ฎด 2023. 11. 6.
728x90

๐Ÿ’ป ๋ฌธ์ œ ์ฃผ์†Œ : Article Views I - LeetCode

 

Article Views I - LeetCode

Can you solve this real interview question? Article Views I - Table: Views +---------------+---------+ | Column Name | Type | +---------------+---------+ | article_id | int | | author_id | int | | viewer_id | int | | view_date | date | +---------------+---

leetcode.com

 

๐Ÿ’ป ๋ฌธ์ œ

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.

- ์ž์‹ ์˜ ๊ธฐ์‚ฌ๋ฅผ ํ•œ ๋ฒˆ์ด๋ผ๋„ ๋ณธ ์ €์ž๋“ค์„ ์ฐพ๋Š” ์‹์„ ๊ตฌํ•˜๋ผ. ์ˆœ์„œ๋Š” id๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•˜๋ผ.

Input๊ณผ Output ์˜ˆ์‹œ

 

๐Ÿ’ป ์ฝ”๋“œ ๋ฐ ํ’€์ด

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

 

728x90
๋ฐ˜์‘ํ˜•

'SQL > LeetCode' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[LeetCode][SQL50] #6. Replace Employee ID With The Unique Identifier  (0) 2023.11.07
[LeetCode][SQL50] #5. Invalid Tweets  (0) 2023.11.06
[LeetCode][SQL50] #3. Big Countries  (0) 2023.11.06
[LeetCode][SQL50] #2. Find Customer Referee  (0) 2023.11.03
[LeetCode][SQL50] #1. Recyclable and Low Fat Products  (0) 2023.11.03