复杂一点的SQL-工作中收集
select gprs_more_type流量溢出频率,row_number() over(order by count(1) DEsc)人数排名
select
count(1)人数
,sum(count(1)) over(ORDER BY count(1) ROWS between unbounded preceding AND current row) sum1 --指第一行至当前行的汇总
,sum(count(1)) over(ORDER BY count(1) ROWS between current row AND unbounded following) sum2 --指当前行到最后一行的汇总
,sum(count(1)) over(ORDER BY count(1) ROWS between 1 preceding AND current row) sum3 --指当前行的上行(rownum-1)到当前行的汇总
,sum(count(1)) over(ORDER BY count(1) ROWS between 1 preceding AND1 following) sum4 --指当前行的上行(rownum-1)到当前行的汇总
,sum(count(1)) over(order by count(1) ROWS between unbounded preceding and unbounded following) sum5 --每行对应的数据汇总
FROM anrpt.rpt_label_info
GROUP BY gprs_more_type
ORDER BY 人数排名 desc
select net_type 网别
,spay_date_first_zy 缴费时间
,count(1)人数
,sum(count(1)) over(PARTITION BY net_type ORDER BY pay_date_first_zy ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)近三月累计缴费人数
,round(avg(count(1)) over(PARTITION BY net_type ORDER BY pay_date_first_zy ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING),1)近三月平均缴费人数
FROM anrpt.rpt_label_info
GROUP BY net_type,pay_date_first_zy
ORDER BY net_type,pay_date_first_zy
浙公网安备 33010602011771号