본문 바로가기

스파르타코딩클럽

Day 6 Today I Learned

오늘 배운 내용

엑셀보자 쉽고 빠른 SQL

1-7 여러 개의 조건으로 필터링하기(논리연산)

and, or, not 사용하기

select *
from customers
where age>=21
and gender='male'

1-8 에러메세지에 당황하지 않고 스스로 문제 해결해보기

너무 당연한 내용

 

숙제

select restaurant_name, customer_id 
from food_orders
where food_preparation_time between 20 and 30
and cuisine_type = 'Korean'

 

2-1 2주차 오늘 배울 것

1주차 복습

2-2 엑셀 대신 SQL로 한번에 계산하기(SUM, AVG, COUNT, MIN, MAX)

select food_preparation_time,
		delivery_time,
		food_preparation_time + delivery_time as total_time
from food_orders

평균, 합 구하기

select sum(food_preparation_time) total_food_preparation_time,
	avg(delivery_time) avg_food_preparation_time
from food_orders

갯수 구하기

select count(1) count_of_orders,
	count(distinct customer_id) count_of_customers
from food_orders

최댓값, 최솟값 구하기

select min(price) min_price,
	max(price) max_price
from food_orders

2-3 실습 where절로 원하는 데이터를 뽑고, 계산해보기

주문 금액이 30,000원 이상인 주문건의 갯수 구하기

select count(1) cnt_orders
from food_orders
where price >= 30000

한국 음식의 주문 당 평균 음식가격

select avg(price) as average_price
from food_orders
where cuisine_type = 'Korean'

2-4 GROUP BY로 범주별 연산 한번에 끝내기

select cuisine_type, sum(price) sum_of_price
from food_orders
group by cuisine_type

group by 안쓰면 에러남

2-5 Query 결과를 정렬하여 업무에 바로 사용하기 (ORDER BY)

정렬하기

select cuisine_type, sum(price) sum_of_price
from food_orders
group by cuisine_type 
order by sum(price) desc

2-6 SQL 구조 마스터

숙제

select cuisine_type, min(price) min_price, max(price) max_price
from food_orders
group by cuisine_type 
order by min(price) desc

 

 

 

느낀점

SQL 강의가 조금 지루하다. 너무 비전공자용인것 같다. 

 

'스파르타코딩클럽' 카테고리의 다른 글

Day 7 Today I Learned  (2) 2024.09.25
Day 6 Today I Learned (2)  (1) 2024.09.24
Day 5 Today I Learned  (1) 2024.09.23
Day 4 Today I Learned  (1) 2024.09.13
Day 3 Today I Learned  (0) 2024.09.12