ex)
SELECT restaurant_name as "음식점",
addr address
FROM food_orders
1) 비교연산자는 모두 사용가능
2) 다양한 조건의 종류 (BETWEEN, IN, LIKE)
select *
from food_orders
where price between 20000 and 30000
SELECT *
FROM customers c
WHERE age in (21,25,27)
select *
from food_orders
where restaurant_name like 'B%'
//테이블에서 B로 시작하는 상점의 주문을 조회하기 때문에 B뒤에 % 붙혀준다.
| 논리연산자 | 의미 | 예시 |
|---|---|---|
| AND | 그리고 | age>20 and gender=’female’ → 나이가 20세 이상이고, 여성 |
| OR | 또는 | age>20 or gender=’female’ → 나이가 20세 이상이거나, 여성 |
| NOT | 아닌 | not gender=’female’ → 여성이 아닌 |
사용방법만 간단히 알자
select sum(food_preparation_time) total_food_preparation_time,
avg(delivery_time) avg_delivery_time
from food_orders

sum과 avg를 계산한 결과.
select count(1) as total_count
from payments
payments에 있는 데이터 개수를 구한다는 의미.
select count(distinct pay_type) as count_of_pay_type
from payments
payments에 있는 pay_type의 종류의 개수를 구하기
select min(price) min_price,
max(price) max_price
from food_orders
select restaurant_name,
max(price) max_price
from food_orders
group by restaurant_name
레스토랑별 최대 주문 금액을 알아야 하므로 resturant_name, max(price)를
적어 준 후 group by restaurant_name 을 통해 묶어준다.
select cuisine_type,
sum(price) sum_of_price
from food_orders
group by cuisine_type
order by sum(price) // 내림차순으로 정렬하고싶다면 desc를 뒤에 붙혀 준다.
내일중이면 강의 듣는것은 끝이 날 것같다.
캠이 도착하면 캠을 설치하여 운용해 보고 코드카타를 들어가면 될 것 같다.