고객 DB SQL 예시문제
- 최초 등록일
- 2021.08.24
- 최종 저작일
- 2020.06
- 10페이지/ MS 워드
- 가격 1,500원
목차
없음
본문내용
내포문
1.SHoes 또는 wear 카테고리에 속하는 제품을 동시에 구매한 주문수를 조회하시오.
Select count(1) as 동시구매주문이력 수
From (
Select *
From tbl_order_detail as A INNER JOIN tbl_product as B INNER JOIN tbl_category as C
ON A.product_no=b.product_no and b.order_no=c.order_no
Where c.category_name in (shoes, wear)
Groupby a.order_no #동시구매
Having count(1)=2 #동시구매
)as D
2. SHOES를 구매한 10대 고객을 조회하시오.
Select distinct D.*
From tbl_customer as D INNER JOIN tbl_order as E
On D.customer_no=E.customer_no
Where D.customer_age between 10 and 19
And
E.order_no in(
select c.order_no
from tbl_product as A INNER JOIN tbl_category as B INNER JOIN tbl_order_detail as C
ON A.category_no=B.category_no and A.product_no=C.product_no
Where B.category_name=shoes
참고 자료
없음