회원(users) 테이블과 주문정보(orders) 테이블을 이용하여 모든 주문내역에 회원정보를 표시하세요.
결과예시
select
orders.order_id,
orders.num_of_item,
concat(users.first_name, ' ', users.last_name) as user_name,
users.street_address,
users.postal_code,
users.city,
users.country
from `thelook_ecommerce.users` as users
left join `thelook_ecommerce.orders` as orders on users.id = orders.user_id
# 강사님 코드
select
t1.order_id,
t1.num_of_item,
concat(t2.first_name, ' ', t2.last_name) as user_name,
t2.street_address,
t2.postal_code,
t2.city,
t2.country
from `thelook_ecommerce.orders` t1
left join `thelook_ecommerce.users` t2 on t1.user_id = t2.id
회원(users) 테이블과 주문정보(orders) 테이블을 이용하여 상품을 주문한 회원의 국가가 ‘United States’이면서 주문 상태가 처리중(Processing)인 정보를 조회하시오.
결과예시
# 강사님 코드
select
orders.order_id,
concat(users.first_name, ' ', users.last_name) as user_name,
users.street_address,
users.postal_code,
users.city,
users.country,
orders.num_of_item
from `thelook_ecommerce.users` as users
left join `thelook_ecommerce.orders` as orders on users.id = orders.user_id
where country = 'United States' and orders.status = 'Processing'
select
t1.order_id,
t2.first_name || ' ' ||t2.last_name as user_name,
t2.street_address,
t2.postal_code,
t2.city,
t2.country,
t1.num_of_item
from `thelook_ecommerce.orders` t1
join `thelook_ecommerce.users` t2 on t1.user_id = t2.id
where t2.country = 'United States'
and t1.status = 'Processing'
회원(users) 테이블과 주문정보(orders) 테이블을 이용하여 국가별 총 상품 주문주(total_order_count)을 조회하시오.