강의

멘토링

커뮤니티

Inflearn Community Q&A

profit069's profile image
profit069

asked

Infrastructure Workshop - Creating a plausible service

Improving MySQL query performance

sql 2번 쿼리 정답이 궁금합니다

Resolved

Written on

·

288

0

정답 예시에서는 91개가 조회되는데 제가 생각한 쿼리는 89개만 조회가 됩니다. 쿼리가 잘못된걸 까요?

SELECT 
c.customerId `고객아이디`, 
c.customername as `고객이름`, 
sum(Quantity) as `주문량` 
FROM OrderDetails od
join Orders o on o.OrderId = od.OrderId
join Customers c on c.customerId = o.customerId
group by o.customerId
order by sum(Quantity) desc
;
네트워크linuxawsmysqlspring-boot

Answer 1

1

profit069님의 프로필 이미지
profit069
Questioner

주문량이 0건인 고객도 있어서 Customers 를 기준으로 left join 을 시켜야 올바르게 나오게 되는 군요 해결했습니다 :)

profit069's profile image
profit069

asked

Ask a question