24.06.24

윤지현·2024년 6월 24일

TIL

목록 보기
16/75

연습문제5) 공부하다보니 팀 프로젝트 시간이 왔어요!

- team_projects

idnamestart_dateend_dateaws_cost
1일조2023-01-012023-01-0730000
2꿈꾸는이조2023-03-152023-03-2250000
3보람삼조2023-11-202023-11-3080000
4사조참치2022-07-012022-07-3075000
  1. team_projects 테이블에서 AWS 예산(aws_cost)이 40000 이상 들어간 프로젝트들의 이름을 선택하는 쿼리를 작성해주세요!
1. select name from team_projects where aws_cost >= 40000
  1. team_projects 테이블에서 2022년에 시작된 프로젝트를 선택하는 쿼리를 작성해주세요! 단, start_date < ‘2023-01-01’ 조건을 사용하지 말고 쿼리를 작성해주세요!
1. select * from team_projects where YEAR(start_date) = 2022
2. select * from team_projects where DATE_FORMAT(start_date, '%Y') = 2022
  1. team_projects 테이블에서 현재 진행중인 프로젝트를 선택하는 쿼리를 작성해주세요. 단, 지금 시점의 날짜를 하드코딩해서 쿼리하지 말아주세요!
1. select * from team_projects where CURDATE() between start_date and end_date
2. select * from team_projects where start_date <= CURDATE() AND end_date >= CURDATE();
  1. team_projects 테이블에서 각 프로젝트의 지속 기간을 일 수로 계산하는 쿼리를 작성해주세요!
1. SELECT id, name, start_date, end_date, DATEDIFF(end_date, start_date) AS duration_days, aws_cost
FROM team_projects;
profile
첫 시작

0개의 댓글