[SQL] 잔존율 retention 집계 하기 D+7, M+1
use workdb2 go WITH ##repeat_interval AS ( SELECT * FROM ( VALUES ('01 day repeart', 1) ,('02 day repeart', 2) ,('03 day repeart', 3) ,('04 day repeart', 4) ,('05 day repeart', 5) ,('06 day repeart', 6) ,('07 day repeart', 7) ) AS a (index_name, interval_date) ) ,##rau_0501_0531 AS ( selectcast(time as date) 'date', server, accountid fromexample2.dbo.all_rau where cast(time as date) between '202..
2022. 9. 26.
[sql] 카테고리별 매출 계산 (ABC 분석, 팬차트, 히스토그램)
카테고리별 매출 소계 집계 select substring(date::text, 6, 2) as months ,category , sum(amount) as total_amount from sale_data group by ROLLUP(months, category) order by months, category ABC 분석 with month_sales as ( select category , sum(amount) as amount from sale_data where date between '2019-01-01' and '2019-01-31' group by category ) , sales_ratio as ( select category ,amount ,round(100.0 * amount / sum..
2022. 9. 26.