PostgreSQL 풀이 | Teams Power Users

2025. 3. 7. 16:48·SQL

문제 1.  Teams Power Users

Write a query to identify the top 2 Power Users who sent the highest number of messages on Microsoft Teams in August 2022. Display the IDs of these 2 users along with the total number of messages they sent. Output the results in descending order based on the count of the messages.

Assumption:
No two users have sent the same number of messages in August 2022.

 

https://datalemur.com/questions/teams-power-users

 

Microsoft SQL Interview Question | DataLemur

Microsoft SQL Interview Question: Write a query to retrieve the top 2 Power Users who sent the highest number of messages.

datalemur.com


💡 문제 풀이 

`내 풀이`

소요 시간 03:10

SELECT sender_id, 
  COUNT(message_id) AS message_count
FROM messages
WHERE EXTRACT (MONTH FROM sent_date) = 8 AND EXTRACT (YEAR FROM sent_date) = 2022
GROUP BY sender_id
ORDER BY message_count desc
LIMIT 2;

💯결과

 

 

'SQL' 카테고리의 다른 글
  • PostgreSQL 풀이 | Top Three Salaries
  • PostgreSQL 풀이 | Active User Retention
  • PostgreSQL 풀이 | Highest-Grossing Items
  • PostgreSQL 풀이 | Histogram of Tweets
초담
초담
4년차 마케터입니다
  • 초담
    그로스마케터의 기록
    초담
  • 전체
    오늘
    어제
  • 글쓰기 관리
    • 분류 전체보기 (117)
      • Data Analytics Project (3)
      • SQL (55)
      • Python (43)
      • GA4 (0)
      • Tableau (8)
      • 아티클 스터디 (7)
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.2
초담
PostgreSQL 풀이 | Teams Power Users
상단으로

티스토리툴바