[PostgreSQL] solvesql LV.3 온라인 쇼핑몰의 월 별 매출액 집계
·
프로그래밍 언어/02. SQL
https://solvesql.com/problems/shoppingmall-monthly-summary/🔍 문제us e-commerce 데이터에서 연-월 별로 취소되지 않은 주문 금액의 합계, 취소된 주문 금액 합계, 전체 합계를 구하시오🎯정답select to_char(o.order_date, 'YYYY-MM') as "order_month", sum(i.price * i.quantity) filter (where o.order_id not like 'C%') as "ordered_amount", sum(i.price * i.quantity) filter (where o.order_id like 'C%') as "canceled_amount", sum(i.price * i.quantity) ..