TIL

3주차 목요일

news0516 2024. 10. 17. 17:21

오늘 배운 내용
SQL 5주차 강의

null 문법

coalesce로 대체 가능

SELECT
...
coalesce(b.age, 20) "null 제거",
...
FROM food_orders a left join customers b on a.customer_id=b.customer_id
WHERE b.age is null

데이터 값이 상식적이지 않은 경우
ex ) 70년대 카드 결제, 2세가 음식 주문 등등..
> 조건문으로 값의 범위를 지정한다
SELECT  customer_id, name, email, gendor, age,
case when age<15 then 15
when age>80 then 80
else age end "범위를 지정해준 age"
FROM customers

데이터베이스 생성 후 피봇테이블 생성
행축 먼저

window 함수
기본 sql 구조 활용 시 복잡한 subquery 문을 사용하거나 여러번의 연산 필요
window  function 에서 자체적으로 제공해주는 기능을 이용하여 편리하게 해결 가능

window_function(argument) over (partition by 그룹 기준 컬럼 order by 정렬 기준)

select date(date) date_type,
date_format(date(date), '%Y') "년",
date_format(date(date), '%m') "월",
date_format(date(date), '%d') "일",
date_format(date(date), '%w') "요일"
from payments

sql 걷기반 퀴즈 마무리,
달리기반 2번까지 진행

남은 웹개발 강의를 빠르게 완강하는 것을 목표로 진행 


팀원과 토의를 통해 여러가지 방법의 해답과 과정 고찰,

달리기반 과제는 응용이 필요한 것 같아 토의 과정이 크게 도움 되었다.

'TIL' 카테고리의 다른 글

4주차 월요일  (1) 2024.10.21
3주차 금요일  (0) 2024.10.18
3주차 수요일  (0) 2024.10.16
3주차 월요일  (0) 2024.10.14
2주차 금요일  (0) 2024.10.11