728x90
1. 코딩 테스트 입문
암호 해독
문자열 정렬하기(1)
-> Stream mapToInt(Integer :: IntValue)를 다루는 데 익숙해지도록 더 연습할 것 ~ 스트림과 람다
2. SQL 강의
강의 : 엑셀보다 쉬운 SQL
JOIN : 주로 left join과 inner join을 사용한다
Join과 Vlookup은 같은 결과를 출력
left(right) join은 합집합 : 겹치지 않는 데이터도 함께 가져온다
inner join은 교집합 : 겹치는 데이터만 가져온다
ex)
select * from enrolleds e
inner join courses c
on e.course_id = c.course_id;
쿼리 순서 : from -> join -> select
- from enrolleds: enrolleds 테이블 데이터 전체를 가져온다.
- inner join courses on e.course_id = c.course_id: courses를 enrolleds 테이블에 붙이는데, enrolleds 테이블의 course_id와 동일한 course_id를 갖는 courses의 테이블을 결합
- select * : 붙여진 모든 데이터를 출력
from에 들어간 테이블을 기준으로, 다른 테이블이 붙는다고 생각하면 편하다
Join의 실행 순서는 항상 from 과 붙어다닌다
ex2)
select u.name, count(u.name) as count_name from orders o
inner join users u
on o.user_id = u.user_id
where u.email like '%naver.com'
group by u.name
쿼리 순서: from → join → where → group by → select
- from orders o: orders 테이블 데이터 전체를 가져오고 o라는 별칭
- inner join users u on o.user_id = u.user_id : users 테이블을 orders 테이블에 붙이는데, orders 테이블의 user_id와 동일한 user_id를 갖는 users 테이블 데이터를 결합 (*users 테이블에 u라는 별칭)
- where u.email like '%naver.com': users 테이블 email 필드값이 naver.com으로 끝나는 값만 조회
- group by u.name: users 테이블의 name값이 같은 값들을 묶는다
- select u.name, count(u.name) as count_name : users 테이블의 name필드와 name 필드를 기준으로 뭉쳐진 갯수를 세어서 출력
결과물 합치기 : Union
ex)
(
select '7월' as month, c.title, c2.week, count(*) as cnt from checkins c2
inner join courses c on c2.course_id = c.course_id
inner join orders o on o.user_id = c2.user_id
where o.created_at < '2020-08-01'
group by c2.course_id, c2.week
order by c2.course_id, c2.week
)
union all
(
select '8월' as month, c.title, c2.week, count(*) as cnt from checkins c2
inner join courses c on c2.course_id = c.course_id
inner join orders o on o.user_id = c2.user_id
where o.created_at > '2020-08-01'
group by c2.course_id, c2.week
order by c2.course_id, c2.week
)
3. 개인 과제 수행
게시물 조회, 삭제기능 개선
ResponseEntity로 반환하는 handleException 메서드의 타입은? + AOP 공부
4. 강의 복습하기
선발대 & 후발대 강의 복습
728x90
'내일배움캠프 4기 스프링 > 내배캠 TIL📘' 카테고리의 다른 글
01. 17 심화 프로젝트 : UML/ ERD (0) | 2023.01.18 |
---|---|
01. 16 TIL : 심화 프로젝트를 위한 회의 (0) | 2023.01.17 |
01. 12 TIL (0) | 2023.01.12 |
01. 11 TIL (0) | 2023.01.11 |
01. 10 TIL (0) | 2023.01.10 |