ย ํ๋งค ์ค์ธ ์ํ ์ค ๊ฐ์ฅ ๋์ ํ๋งค๊ฐ๋ฅผ ์ถ๋ ฅ ย
SELECT max(price) as max_price
from product;
์ํ์ฝ๋ ๋ณ ๋งค์ถ์ก(ํ๋งค๊ฐ * ํ๋งค๋) ํฉ๊ณ๋ฅผ ์ถ๋ ฅ (๋งค์ถ์ก์ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ, ๋งค์ถ์ก์ด ๊ฐ๋ค๋ฉด ์ํ์ฝ๋๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์ ์ ๋ ฌ)
SELECT P.product_code, sum(P.price*O.sales_amount) sales
from product P join offline_sale O
on P.product_id = O.product_id
group by P.product_code
order by sales desc, P.product_code;
๋ , ์, ์ฑ๋ณ ๋ณ๋ก ์ํ์ ๊ตฌ๋งคํ ํ์์๋ฅผ ์ง๊ณ (๋ , ์, ์ฑ๋ณ์ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์ ์ ๋ ฌ, ์ฑ๋ณ ์ ๋ณด๊ฐ ์๋ ๊ฒฝ์ฐ ๊ฒฐ๊ณผ์์ ์ ์ธ)
SELECT year(O.sales_date) year, month(O.sales_date) month, U.gender, count(distinct O.user_id) users
from user_info U join online_sale O
on U.user_id = O.user_id
where U.gender is not null
group by year, month, U.gender
order by year, month, U.gender;