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๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์ ์ ๋ ฌํ๋ผ.
๐ป ์ฝ๋ ๋ฐ ํ์ด
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 |