[PostgreSQL] 매출을 파악하기 위한 데이터 추출2 (종합 쿼리)
▶︎ 연/월별로 다음 데이터를 뽑는 종합 쿼리 판매 횟수 평균 구매액 매출액 누계 매출액 작년 (동월) 매출액 작년 (동월) 비율 with daily_purchase as ( select dt , substring(dt, 1, 4) as year , substring(dt, 6, 2) as month , substring(dt, 9, 2) as date , sum(purchase_amount) as purchase_amount , count(order_id) as orders from purchase_log group by 1 ), monthly_purchase as( select year , month , sum(orders) as orders , avg(purchase_amount) as avg_am..
2024. 1. 26.