Notice
Recent Posts
Recent Comments
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- rrule
- DATE_FORMAT
- limit
- 정규분포
- 태블로
- join
- 신뢰구간
- datediff
- pivot table
- floor
- 표준오차
- split
- 표분편차
- concat
- curdate
- 프로그래머스
- 레이더차트
- 재귀쿼리
- Recursive
- tableau
- 표본분포
- 재퀴쿼리
- 데이터 리터러시
- python
- lambda
- 모집단
- dateofmonth
- calesce
- merge
- truncate
Archives
- Today
- Total
반응형
hyezdata 님의 블로그
[SQL] Students and Examinations 본문
# 학생들이 각 과목마다 시험 본 횟수
# 학생들 id랑 과목명 순으로
select s.student_id, s.student_name, sub.subject_name, count(e.subject_name) as attended_exams
from Students s cross join Subjects sub left join Examinations e
on s.student_id=e.student_id and e.subject_name = sub.subject_name
group by student_name, sub.subject_name
order by s.student_id, sub.subject_name
★ 먼저, CROSS JOIN 으로 빈 과목들 채워주는 거 잊지 말기
★ select 절에서 어떤 테이블의 변수를 써야하는지 잘 선택 (아래 사진 참고)
https://leetcode.com/problems/students-and-examinations/description/
728x90
반응형
'내일배움캠프 > 코드카타' 카테고리의 다른 글
[Python] 가운데 글자 가져오기 (0) | 2025.05.09 |
---|---|
[SQL] Rising Temperature (0) | 2025.05.08 |
[SQL] Average Time of Process per Machine (0) | 2025.05.08 |
[파이썬] 제일 작은 수 제거하기 (0) | 2025.05.08 |
입양 시각 구하기(2) (0) | 2025.04.11 |