[LeetCode] 2356. Number of Unique Subjects Taught by Each Teacher

Chobby·2025년 10월 27일

LeetCode

목록 보기
718/800

😎풀이

  1. Teacher 테이블 조회
  2. teacher_id를 기준으로 그룹화
  3. teacher_id 조회
  4. 중복이 제거된 subject_id의 수를 cnt라는 명칭으로 조회
SELECT
    teacher_id,
    COUNT(DISTINCT subject_id) AS cnt
FROM
    Teacher
GROUP BY
    teacher_id
profile
내 지식을 공유할 수 있는 대담함

0개의 댓글