퀘스트 중 아직 배우지 않은 날짜 관련 함수들이 많이 나와서 GPT선생님과 함께 학습
현재 날짜와 시간: CURRENT_DATE, CURRENT_TIMESTAMP, NOW()
날짜 추출: YEAR(), MONTH(), DAY()
날짜 차이 계산: DATEDIFF(), TIMESTAMPDIFF()
날짜 더하기/빼기: DATE_ADD(), DATE_SUB()
날짜 형식 변환: STR_TO_DATE(), DATE_FORMAT()
날짜 특정 부분 추출: EXTRACT(), LAST_DAY()
NULL 처리: IFNULL(), COALESCE()
이중에 current_date와 year, datediff 함수 사용함
#1
select name, track
from sparta_students
#2
select*
from sparta_students
where track <> 'unity'
#3
select*
from sparta_students
where enrollment_year in(2021, 2023)
#4
select enrollment_year
from sparta_students
where track = 'Node.js'
and grade = 'A'
#1
select name
from team_projects
where aws_cost>=40000
#2
select*
from team_projects
where start_date like'2022%'
#like는 문자열에서만 사용가능하므로 날짜가 문자열 형식(yyyy-mm-dd)인 경우 사용가능함
where year(start_date) = 2022
#날짜함수를 사용하는것이 더 일반적임(연도추출)
#3
#하드코딩이란 직적접인 숫자, 날짜를 적는 것을 말함. (ex, >=40000, 2024-11-07 등)
select*
from team_projects
where start_date <= current_date
and end_date>= current_date
#4
select name, datediff(end_date, start_date) "프로젝트 지속기간"
from team_projects드를 입력하세요
걷기반 실시간 수업 참여
조건문 if, elif, else
반복문 for, in, while
break, continue 함수 학습
sql 강의에서 함수가 여러개 쓰이니까 조금 헷갈리기 시작했다.
강의자료 보면서 따로 복습 할 시간이 필요할 듯 하다.
여전히 쉽지않지만 아직 4일차니까^^
어떤 분야 또는 과제든 이런 초보의 시절을 거쳐야 1인분을 할 수 있는 사람이 될 수 있듯, 하다보면 언젠간 능숙해질 날이 오겠지