12/3
44)
select o.id, p.name
from products p join orders o on p.id=o.product_id
45)
select p.id,
sum(p.price*o.quantity) as all_sales
from products p join orders o on p.id=o.product_id
group by 1
order by 2 desc
limit 1
46)
select p.id,
sum(o.quantity)
from products p join orders o on p.id=o.product_id
group by p.id
47)
select p.name
from products p join orders o on p.id=o.product_id
where o.order_date >='2023-03-03'
- order_date가 문자열이라 ' ' 를 작성해야 제대로 출력됨
48)
select p.name,
o.quantity
from products p join orders o on p.id=o.product_id
order by 2 desc
limit 1
49)
select p.id,
avg(o.quantity) avg_quantity
from products p join orders o on p.id=o.product_id
group by 1
order by 1
50)
select p.name
from products p left join orders o on p.id=o.product_id
where o.id is null
'내일배움캠프 > 사전캠프 퀘스트' 카테고리의 다른 글
[내일배움캠프]_달리기반 LV4 (0) | 2024.12.05 |
---|---|
[내일배움캠프]_달리기반 1-3 (0) | 2024.12.04 |
[내일배움캠프]_사전캠 SQL 퀘스트 4일차 (0) | 2024.12.02 |
[내일배움캠프]_사전캠 SQL 퀘스트 3일차 (0) | 2024.12.02 |
[내일배움캠프]_사전캠 SQL 퀘스트 2일차 (1) | 2024.11.28 |