关于统计时间切片标签的一些sql

------当天付费明细表
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_ffmx;
create table rpt.tmp_mm_rb_daily_ffmx as
select a.* FROM
(select
c.feemsisdn,
c.destmsisdn,
c.day,
c.price/1000 fee,
c.contentid,
dc.content_name,
c.ordernumber,
c.cdrtime,
c.createtime,
c.servcode,p.province_id,p.province as province_name,
case when b.paytype=1 and b.thirdapptype in (14,17) then '应用内计费'
when b.paytype=1 and b.thirdapptype=15 then '网页类计费应用'
ELSE '下载计费' end fftype,row_number()over(distribute by c.ordernumber sort by c.cdrtime) as rnfrom ods.ods_mm_cssp_cdr c  LEFT OUTER JOIN  dim.dim_mm_phone_city p ON substring(c.feemsisdn,1,7) =p.prefixnumLEFT OUTER JOIN dim.dim_mm_content dc ON  c.contentid=dc.content_id
LEFT OUTER JOIN dim.dim_mm_service_content b ON  c.servcode=b.servicecodewhere c.day =  date_sub('${hiveconf:CURRENT_DATE}',  1)
) a
where a.rn=1;------180天付费明细表
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_180ffmx;
create table rpt.tmp_mm_rb_daily_180ffmx as
select t.day, t.feemsisdn,t.province_id, t.province_name, t.contentid,t.content_name,t.fftype,count(t.ordernumber) ffcs,sum(t.fee) fee
FROM (
select a.* FROM
(selectc.feemsisdn,c.destmsisdn,c.day,c.price/1000 fee,c.contentid,dc.content_name,c.ordernumber,p.province_id,p.province as province_name,case when b.paytype=1 and b.thirdapptype in (14,17) then '应用内计费'
when b.paytype=1 and b.thirdapptype=15 then '网页类计费应用'
ELSE '下载计费' end fftype,row_number()over(distribute by c.ordernumber sort by c.cdrtime) as rnfrom ods.ods_mm_cssp_cdr c LEFT OUTER JOIN  dim.dim_mm_phone_city p ON substring(c.feemsisdn,1,7) =p.prefixnumLEFT OUTER JOIN dim.dim_mm_content dc ON  c.contentid=dc.content_idLEFT OUTER JOIN dim.dim_mm_service_content b ON  c.servcode=b.servicecodewhere c.day >=  date_sub('${hiveconf:CURRENT_DATE}',  181)and  c.day <=  date_sub('${hiveconf:CURRENT_DATE}',  1)
) a where a.rn=1
) tgroup by t.day, t.feemsisdn, t.province_id,t.province_name, t.contentid,t.content_name,t.fftype;------0-6点的订单量/总订单量(time)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb1;
create table rpt.tmp_mm_rb_daily_tb1 as
select a.day,a.province_id,a.province_name,a.contentid,a.content_name,a.fftype,sum(a.fee) amount,var_pop(a.ordernumber) charging_point_concentration,count(a.ordernumber) order_number,count(distinct a.feemsisdn) user_number,sum(a.fee)/count( a.ordernumber) avg_amount,sum(a.fee)/count(distinct a.feemsisdn) amount_per_user,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) in ('00','01','02','03','04','05','06') then a.ordernumber end) /count( a.ordernumber) time,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '00' then a.ordernumber end) /count( a.ordernumber) time0,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '01' then a.ordernumber end) /count( a.ordernumber) time1,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '02' then a.ordernumber end) /count( a.ordernumber) time2,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '03' then a.ordernumber end) /count( a.ordernumber) time3,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '04' then a.ordernumber end) /count( a.ordernumber) time4,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '05' then a.ordernumber end) /count( a.ordernumber) time5,count( case when hour(from_unixtime(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')) = '06' then a.ordernumber end) /count( a.ordernumber) time6from rpt.tmp_mm_rb_daily_ffmx agroup by a.day,a.province_id,a.province_name,a.contentid,a.content_name,a.fftype;------半年内未付费的当日付费用户数/总付费用户数(new_user_6months1)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb2;
create table rpt.tmp_mm_rb_daily_tb2 as
select t1.day,t1.province_id,t1.province_name,t1.contentid,t1.content_name,t1.fftype,t2.ffyhs /t1.ffyhs  new_user_6months1
from (select  tt.day,tt.province_id, tt.province_name, tt.contentid,tt.content_name,tt.fftype, count(distinct tt.feemsisdn) ffyhs FROM rpt.tmp_mm_rb_daily_ffmx ttGROUP BY tt.day,tt.province_id, tt.province_name, tt.contentid,tt.content_name,tt.fftype) t1 LEFT OUTER JOIN (select tt.province_id, tt.contentid,tt.content_name, tt.fftype, count(distinct tt.feemsisdn) ffyhsfrom (select a.feemsisdn, b.feemsisdn as bfeemsisdn from rpt.tmp_mm_rb_daily_ffmx a LEFT OUTER JOIN  rpt.tmp_mm_rb_daily_180ffmx b ON(a.feemsisdn=b.feemsisdn AND  b.day <  date_sub('${hiveconf:CURRENT_DATE}',  1))where b.feemsisdn is NULL) t  JOIN rpt.tmp_mm_rb_daily_ffmx tt  ON t.feemsisdn = tt.feemsisdn GROUP BY  tt.province_id,tt.contentid,tt.content_name,tt.fftype
) t2 ON (t1.province_id=t2.province_id and t1.contentid=t2.contentid and t1.fftype=t2.fftype);------半年内未在该APP付费的当日付费用户数/总付费用户数(new_user_6months2)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb3;
create table rpt.tmp_mm_rb_daily_tb3 as
select t1.day,t1.province_id,t1.province_name,t1.contentid,t1.content_name,t1.fftype,t2.ffyhs /t1.ffyhs  new_user_6months2
from (select  tt.day,tt.province_id, tt.province_name, tt.contentid,tt.content_name,tt.fftype, count(distinct tt.feemsisdn) ffyhs FROM rpt.tmp_mm_rb_daily_ffmx ttGROUP BY tt.day,tt.province_id, tt.province_name, tt.contentid,tt.content_name,tt.fftype) t1 LEFT OUTER JOIN (select tt.province_id, tt.contentid, tt.content_name,tt.fftype,count(distinct tt.feemsisdn) ffyhsfrom (select a.feemsisdn, b.feemsisdn as bfeemsisdn from rpt.tmp_mm_rb_daily_ffmx a LEFT OUTER JOIN  rpt.tmp_mm_rb_daily_180ffmx b ON(a.feemsisdn=b.feemsisdn AND a.contentid=b.contentid AND b.day <date_sub('${hiveconf:CURRENT_DATE}',  1))where b.feemsisdn is NULL) t  JOIN rpt.tmp_mm_rb_daily_ffmx tt  ON t.feemsisdn = tt.feemsisdn GROUP BY  tt.province_id,tt.contentid,tt.content_name,tt.fftype
) t2 ON (t1.province_id=t2.province_id and t1.contentid=t2.contentid and t1.fftype=t2.fftype);------三个月内未付费的当日付费用户数/总付费用户数(new_user_3months1)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb4;
create table rpt.tmp_mm_rb_daily_tb4 as
select t1.day,t1.province_id,t1.province_name,t1.contentid,t1.content_name,t1.fftype,t2.ffyhs /t1.ffyhs  new_user_3months1
from (select  tt.day,tt.province_id, tt.province_name, tt.contentid,  tt.content_name,tt.fftype,count(distinct tt.feemsisdn) ffyhs FROM rpt.tmp_mm_rb_daily_ffmx ttGROUP BY tt.day,tt.province_id, tt.province_name, tt.contentid, tt.content_name,tt.fftype) t1 LEFT OUTER JOIN (select tt.province_id, tt.contentid,tt.fftype, count(distinct tt.feemsisdn) ffyhsfrom (select a.feemsisdn, b.feemsisdn as bfeemsisdn from rpt.tmp_mm_rb_daily_ffmx a LEFT OUTER JOIN  rpt.tmp_mm_rb_daily_180ffmx b ON(a.feemsisdn=b.feemsisdn AND b.day >= date_sub('${hiveconf:CURRENT_DATE}',  91))where b.feemsisdn is NULL) t  JOIN rpt.tmp_mm_rb_daily_ffmx tt  ON t.feemsisdn = tt.feemsisdn GROUP BY  tt.province_id,tt.contentid, tt.content_name,tt.fftype
) t2 ON (t1.province_id=t2.province_id and t1.contentid=t2.contentid and t1.fftype=t2.fftype);------三个月内未在该APP付费的当日付费用户数/总付费用户数(new_user_3months2)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb5;
create table rpt.tmp_mm_rb_daily_tb5 as
select t1.day,t1.province_id,t1.province_name,t1.contentid,t1.content_name,t1.fftype,t2.ffyhs /t1.ffyhs  new_user_3months2
from (select  tt.day,tt.province_id, tt.province_name, tt.contentid, tt.content_name,tt.fftype,count(distinct tt.feemsisdn) ffyhs FROM rpt.tmp_mm_rb_daily_ffmx ttGROUP BY tt.day,tt.province_id, tt.province_name, tt.contentid,tt.content_name,tt.fftype) t1 LEFT OUTER JOIN (select tt.province_id, tt.contentid, tt.content_name,tt.fftype,count(distinct tt.feemsisdn) ffyhsfrom (select a.feemsisdn, b.feemsisdn as bfeemsisdn from rpt.tmp_mm_rb_daily_ffmx a LEFT OUTER JOIN  rpt.tmp_mm_rb_daily_180ffmx b ON(a.feemsisdn=b.feemsisdn AND a.contentid=b.contentid AND b.day >=  date_sub('${hiveconf:CURRENT_DATE}',  91))where b.feemsisdn is NULL) t  JOIN rpt.tmp_mm_rb_daily_ffmx tt  ON t.feemsisdn = tt.feemsisdn GROUP BY  tt.province_id,tt.contentid,tt.content_name,tt.fftype
) t2 ON (t1.province_id=t2.province_id and t1.contentid=t2.contentid and t1.fftype=t2.fftype);------(当日付费次数-昨日付费次数)/昨日付费次数(times_rose_daily) or (当日人均付费金额-昨日人均付费金额)/昨日人均付费金额(amount_per_head_rose_daily)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb6ortb8;
create table rpt.tmp_mm_rb_daily_tb6ortb8 as
select t1.day,t1.province_name,t1.province_id,t1.contentid,t1.content_name,t1.fftype,IF(t2.bffcs is NULL,0,(t1.affcs - t2.bffcs)/t2.bffcs) times_rose_daily,IF(t2.brjfee is NULL,0,(t1.arjfee - t2.brjfee) / t2.brjfee ) amount_per_head_rose_dailyfrom(select a1.day,a1.province_id,a1.province_name,a1.contentid,a1.content_name,a1.fftype,sum(a1.ffcs) affcs,sum(a1.fee) afee,sum(a1.fee) / count(distinct a1.feemsisdn) arjfeefrom rpt.tmp_mm_rb_daily_180ffmx a1where a1.day = date_sub('${hiveconf:CURRENT_DATE}',  1)group by a1.day, a1.province_id,a1.province_name, a1.contentid,a1.content_name,a1.fftype) t1LEFT OUTER JOIN(select a2.day,a2.province_name,a2.province_id,a2.contentid,a2.content_name,a2.fftype,count(distinct a2.feemsisdn) bffyhs,sum(a2.ffcs) bffcs,sum(a2.fee) bfee,sum(a2.fee) / count(distinct a2.feemsisdn) brjfeefrom rpt.tmp_mm_rb_daily_180ffmx a2where a2.day = from_unixtime(unix_timestamp(date_sub('${hiveconf:CURRENT_DATE}',  2),'yyyy-MM-dd'),'yyyyMMdd')group by a2.day, a2.province_id,a2.province_name, a2.contentid,a2.content_name,a2.fftype ) t2ON  (t1.province_id=t2.province_id and t1.contentid = t2.contentid  and t1.fftype=t2.fftype);------(当日到前6日付费次数-前7日到前13日付费次数)/前7日到前13日付费次数(times_rose_7days) or (当日到前6日人均付费金额-前7日到前13日人均付费金额)/前7日到前13日人均付费金额(amount_per_head_rose_7days)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb7ortb9;
create table rpt.tmp_mm_rb_daily_tb7ortb9 as
select tt.day,tt.province_id,tt.province_name,tt.contentid,tt.content_name,tt.fftype,IF(t.bffcs is NULL,0,(t.affcs - t.bffcs)/t.bffcs) times_rose_7days,IF(t.brjfee is NULL,0,(t.arjfee - t.brjfee) / t.brjfee ) amount_per_head_rose_7daysfrom rpt.tmp_mm_rb_daily_tb1 ttLEFT OUTER JOIN (SELECT t1.province_id,t1.province_name,t1.contentid,t1.content_name,t1.fftype,t1.affcs,t1.afee,t1.arjfee,t2.bffyhs,t2.bffcs,t2.bfee,t2.brjfee from( select a1.province_id,a1.province_name,a1.contentid,a1.content_name,a1.fftype,sum(a1.ffcs) affcs,sum(a1.fee) afee,sum(a1.fee) / count(distinct a1.feemsisdn) arjfeefrom rpt.tmp_mm_rb_daily_180ffmx a1where a1.day >=  date_sub('${hiveconf:CURRENT_DATE}',  7)group by a1.province_id, a1.province_name, a1.contentid,a1.content_name,a1.fftype) t1LEFT OUTER JOIN(select a2.province_id,a2.province_name,a2.contentid,a2.content_name,a2.fftype,count(distinct a2.feemsisdn) bffyhs,sum(a2.ffcs) bffcs,sum(a2.fee) bfee,sum(a2.fee) / count(distinct a2.feemsisdn) brjfeefrom rpt.tmp_mm_rb_daily_180ffmx a2where a2.day >=  date_sub('${hiveconf:CURRENT_DATE}',  14)and  a2.day <  date_sub('${hiveconf:CURRENT_DATE}',  7)group by a2.province_id, a2.province_name, a2.contentid,a2.content_name,a2.fftype) t2ON  (t1.province_id=t2.province_id and t1.contentid = t2.contentid   and t1.fftype=t2.fftype)) tON (tt.province_id=t.province_id and tt.contentid = t.contentid   and tt.fftype=t.fftype);------时间间隔
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_interval;
CREATE TABLE rpt.tmp_mm_rb_daily_interval AS
SELECT  A.*,(CASE WHEN A.feemsisdn=LAG(A.feemsisdn) over(partition by a.province_id order by a.cdrtime)AND A.CONTENTID= LAG(A.CONTENTID) over(partition by a.province_id order by a.cdrtime)THEN unix_timestamp(a.cdrtime,'yyyyMMddHHmmss') - lag(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss')) over(partition by a.province_id order by a.cdrtime) END )  in_interval,(CASE WHEN A.feemsisdn=LAG(A.feemsisdn) over(partition by a.province_id order by a.cdrtime)AND A.CONTENTID<> LAG(A.CONTENTID) over(partition by a.province_id order by a.cdrtime)THEN unix_timestamp(a.cdrtime,'yyyyMMddHHmmss') - lag(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss')) over(partition by a.province_id order by a.cdrtime) END )  cross_interval,(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss') - lag(unix_timestamp(a.cdrtime,'yyyyMMddHHmmss')) over(partition by a.province_id order by a.cdrtime))  on_intervalFROM rpt.tmp_mm_rb_daily_ffmx A;------订购间隔时间(in_interval,in_interval_5s_percent,in_interval_120s_percent,in_interval,in_interval_5s_percent,in_interval_120s_percent,charging_point_concentration,cross_interval,cross_interval_5s_percent,cross_interval_120s_percent)
DROP TABLE IF EXISTS rpt.tmp_mm_rb_daily_tb10;
create table rpt.tmp_mm_rb_daily_tb10 as
select a.day,a.province_id,a.province_name,a.contentid,a.content_name,a.fftype,avg(a.in_interval) in_interval,avg(a.cross_interval) cross_interval,avg(a.on_interval) on_interval,count( case when a.in_interval<5 then a.ordernumber end)/count( a.ordernumber) in_interval_5s_percent,count( case when a.in_interval<120 then a.ordernumber end)/count(a.ordernumber) in_interval_120s_percent,count( case when a.cross_interval<5 then a.ordernumber end)/count(a.ordernumber) cross_interval_5s_percent,count( case when a.cross_interval<120 then a.ordernumber end)/count(a.ordernumber) cross_interval_120s_percent,count( case when a.on_interval<5 then a.ordernumber end)/count(a.ordernumber) on_interval_5s_percent,count( case when a.on_interval<120 then a.ordernumber end)/count(a.ordernumber) on_interval_120s_percent
from rpt.tmp_mm_rb_daily_interval agroup by a.day,a.province_id,a.province_name,a.contentid,a.content_name,a.fftype;------整合数据建表
DROP TABLE IF EXISTS rpt.rpt_mm_daily_pay;
create table rpt.rpt_mm_daily_pay as
select t1.day,t1.province_id,t1.province_name,t1.contentid,t1.content_name,t1.fftype,t1.amount,t1.order_number,t1.user_number,t1.avg_amount,t1.amount_per_user,t1.time,t1.time0,t1.time1,t1.time2,t1.time3,t1.time4,t1.time5,t1.time6,t1.new_user_6months1,t1.new_user_6months2,t1.new_user_3months1,t1.new_user_3months2,t1.people_rose_daily,t1.people_rose_7days,t1.amount_per_head_rose_daily,t1.amount_per_head_rose_7days,t1.interval,t1.interval_5s_percent,t1.interval_120s_percent,t1.in_interval,t1.in_interval_5s_percent,t1.in_interval_120s_percent,t1.charging_point_concentration,t1.cross_interval,t1.cross_interval_5s_percent,t1.cross_interval_120s_percentfrom (select t.day,t.province_id,t.contentid,t.content_name,t.province_name,t.fftype,round(sum(t.amount),2) amount,sum(t.order_number) order_number,sum(t.user_number) user_number,round(sum(t.avg_amount), 2) avg_amount,round(sum(t.amount_per_user), 2) amount_per_user,round(sum(t.time),2) time,round(sum(t.time0),2) time0,round(sum(t.time1),2) time1,round(sum(t.time2),2) time2,round(sum(t.time3),2) time3,round(sum(t.time4),2) time4,round(sum(t.time5),2) time5,round(sum(t.time6),2) time6,round(sum(t.new_user_6months1), 2) new_user_6months1,round(sum(t.new_user_6months2), 2) new_user_6months2,round(sum(t.new_user_3months1), 2) new_user_3months1,round(sum(t.new_user_3months2), 2) new_user_3months2,round(sum(t.people_rose_daily), 2) people_rose_daily,round(sum(t.people_rose_7days), 2) people_rose_7days,round(sum(t.amount_per_head_rose_daily), 2) amount_per_head_rose_daily,round(sum(t.amount_per_head_rose_7days), 2) amount_per_head_rose_7days,round(sum(t.on_interval), 2) interval,round(sum(t.on_interval_5s_percent), 2) interval_5s_percent,round(sum(t.on_interval_120s_percent), 2) interval_120s_percent,round(sum(t.in_interval), 2) in_interval,round(sum(t.in_interval_5s_percent), 2) in_interval_5s_percent,round(sum(t.in_interval_120s_percent), 2) in_interval_120s_percent,round(sum(t.charging_point_concentration), 2) charging_point_concentration,round(sum(t.cross_interval), 2) cross_interval,round(sum(t.cross_interval_5s_percent), 2) cross_interval_5s_percent,round(sum(t.cross_interval_120s_percent), 2) cross_interval_120s_percentfrom (select a1.day,a1.province_id,a1.contentid,a1.content_name,a1.province_name,a1.fftype,a1.amount,a1.order_number,a1.user_number,a1.avg_amount,a1.amount_per_user,a1.time,a1.time0,a1.time1,a1.time2,a1.time3,a1.time4,a1.time5,a1.time6,0 new_user_6months1,0 new_user_6months2,0 new_user_3months1,0 new_user_3months2,0 people_rose_daily,0 people_rose_7days,0 amount_per_head_rose_daily,0 amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,a1.charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb1 a1union ALLselect a2.day,a2.province_id,a2.contentid,a2.content_name,a2.province_name,a2.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,a2.new_user_6months1,0 new_user_6months2,0 new_user_3months1,0 new_user_3months2,0 people_rose_daily,0 people_rose_7days,0 amount_per_head_rose_daily,0 amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,0 charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb2 a2union ALLselect a3.day,a3.province_id,a3.contentid,a3.content_name,a3.province_name,a3.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,0 new_user_6months1,a3.new_user_6months2,0 new_user_3months1,0 new_user_3months2,0 people_rose_daily,0 people_rose_7days,0 amount_per_head_rose_daily,0 amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,0 charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb3 a3union ALLselect a4.day,a4.province_id,a4.contentid,a4.content_name,a4.province_name,a4.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,0 new_user_6months1,0 new_user_6months2,a4.new_user_3months1,0 new_user_3months2,0 people_rose_daily,0 people_rose_7days,0 amount_per_head_rose_daily,0 amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,0 charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb4 a4union ALLselect a5.day,a5.province_id,a5.contentid,a5.content_name,a5.province_name,a5.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,0 new_user_6months1,0 new_user_6months2,0 new_user_3months1,a5.new_user_3months2,0 people_rose_daily,0 people_rose_7days,0 amount_per_head_rose_daily,0 amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,0 charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb5 a5union ALLselect a6.day,a6.province_id,a6.contentid,a6.content_name,a6.province_name,a6.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,0 new_user_6months1,0 new_user_6months2,0 new_user_3months1,0 new_user_3months2,a6.times_rose_daily people_rose_daily,0 people_rose_7days,a6.amount_per_head_rose_daily,0 amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,0 charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb6ortb8 a6union ALLselect a7.day,a7.province_id,a7.contentid,a7.content_name,a7.province_name,a7.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,0 new_user_6months1,0 new_user_6months2,0 new_user_3months1,0 new_user_3months2,0 people_rose_daily,a7.times_rose_7days people_rose_7days,0 amount_per_head_rose_daily,a7.amount_per_head_rose_7days amount_per_head_rose_7days,0 on_interval,0 on_interval_5s_percent,0 on_interval_120s_percent,0 in_interval,0 in_interval_5s_percent,0 in_interval_120s_percent,0 charging_point_concentration,0 cross_interval,0 cross_interval_5s_percent,0 cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb7ortb9 a7union ALLselect a8.day,a8.province_id,a8.contentid,a8.content_name,a8.province_name,a8.fftype,0 amount,0 order_number,0 user_number,0 avg_amount,0 amount_per_user,0 time,0 time0,0 time1,0 time2,0 time3,0 time4,0 time5,0 time6,0 new_user_6months1,0 new_user_6months2,0 new_user_3months1,0 new_user_3months2,0 people_rose_daily,0 people_rose_7days,0 amount_per_head_rose_daily,0 amount_per_head_rose_7days,a8.on_interval,a8.on_interval_5s_percent,a8.on_interval_120s_percent,a8.in_interval,a8.in_interval_5s_percent,a8.in_interval_120s_percent,0 charging_point_concentration,a8.cross_interval,a8.cross_interval_5s_percent,a8.cross_interval_120s_percentfrom rpt.tmp_mm_rb_daily_tb10 a8 ) tgroup by t.day, t.province_id, t.province_name,t.contentid,t.content_name,t.fftype) t1order by t1.amount desc;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/508763.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

hadoop 二次开发DatanodeWriteTimeout设置

int getDatanodeWriteTimeout(int numNodes) {return this.dfsClientConf.confTime > 0 ? this.dfsClientConf.confTime 5000 * numNodes : 0;}int getDatanodeReadTimeout(int numNodes) {return this.dfsClientConf.socketTimeout > 0 ? 5000 * numNodes this.dfsC…

聚类算法

假定样本集 D {X1&#xff0c; 的&#xff0c;…&#xff0c; Xm} 包含 m 个无标记样本&#xff0c; 每个样本 X (X1; X2;… ; Xn) 是一个 n 维特征向量&#xff0c;则聚类算法将样本 集 D 划分为 k 个不相交的簇 {Gl I l 1&#xff0c; 2;… &#xff0c;时&#xff0c;其中…

k-means均值向量

给定样本集 D {Xl) 的&#xff0c;… ,xm}, “k 均值” (k-means )算法针对聚类所 得簇划分 C {C1, C2,…, Ck} 最小化平方误差 ι ELL Ilx 一队IIL il EGi 其中队甘il LEGi X 是簇 q 的均值向量.在一定程度上 刻画了簇内样本围绕簇均值向量的紧密程度&#xff0c; E 值越小则…

学习向量量化

与 k 均值算法类似&#xff0c;“学习向量量化” (Learning Vector Quantization&#xff0c;简 称 LVQ)也是试图找到一组原型向量来刻画聚类结构&#xff0c; 但与一般聚类算法不同 的是&#xff0c; LVQ 假设数据样本带有类别标记&#xff0c;学习过程利用样本的这些监督信息…

k 近邻加权平均

k 近邻(k-Nearest Neighbor&#xff0c;简称 kNN)学习是一种常用的监督学习方法&#xff0c; 其工作机制非常简单: 给定测试样本?基于某种距离度量找出训练集中与其最 靠近的 k 个训练样本&#xff0c;然后基于这 k 个"邻居"的信息来进行预测. 通常&#xff0c; 在分…

k 近邻降维

k 近邻(k-Nearest Neighbor&#xff0c;简称 kNN)学习是一种常用的监督学习方法&#xff0c; 其工作机制非常简单: 给定测试样本?基于某种距离度量找出训练集中与其最 靠近的 k 个训练样本&#xff0c;然后基于这 k 个"邻居"的信息来进行预测. 通常&#xff0c; 在分…

维度建模工具

幵始维度建模工作前&#xff0c;项目组需要理解业务需求&#xff0c;以及作为基础的源数据的实际情况。 通过与、 Ik务代表交流来发现需求&#xff0c;用于理解他们的基于关键性能指标、竞争性商业问题、 决策制定过程、支持分析需求的目标。同时&#xff0c;数据实际情况可以通…

Cube和Grouping 和Rollup

增强的聚合 Cube和Grouping 和Rollup 这几个分析函数通常用于OLAP中&#xff0c;不能累加&#xff0c;而且需要根据不同维度上钻和下钻的指标统计&#xff0c;比如&#xff0c;分小时、天、月的UV数。 GROUPING SETS 在一个GROUP BY查询中&#xff0c;根据不同的维度组合进行聚…

常见维度建模错误

需要避免的常见维度建模错误 错误 10: 在事实表中放入文本属性 要从数据仓库事实表中 挑出这些文本属性&#xff0c;并将它们放入维度表中。 错误 9: 限制使用冗长的描述符以节省空间 维度表从几何上看总是比事实表小很多。 错误 8: 将层次划分为多个维度 以用户看来最自然最 有…

2020-09-21

columns has 234 elements while hbase.columns.mapping has 92 elements (counting the key if implicit)) 根本原因&#xff1a; 对于4000个字符&#xff0c;hive Metastore中SERDE_PARAMS表中PARAM_VALUE字段的字符限制是此问题的根本原因。 此限制可防止Hive创建具有高列数…

2020-09-23

insert into table ads_user_action_convert_day select ‘2019-02-10’, uv.day_count, ua.order_count, cast(ua.order_count/uv.day_count as decimal(10,2)) visitor2order_convert_ratio, ua.payment_count, cast(ua.payment_count/ua.order_count as decimal(10,2)) orde…

2020-09-28

Mybatis中#{}和${} 1、#{}将传入的数据都当成一个字符串&#xff0c;会对自动传入的数据加一个引号&#xff08;单引号&#xff1f;双引号&#xff1f;加了引号就对了&#xff09;如&#xff1a; //传入的值是sex order by #{column} 解析后为 order by “sex” //将会出错 2…

PageUtil

Data NoArgsConstructor public class PageUtil implements Serializable {private static final long serialVersionUID 1L;/*** 总记录数*/private int totalCount;/*** 每页记录数*/private int pageSize;/*** 总页数*/private int totalPage;/*** 当前页数*/private int c…

springboot+事务,多张表的操作事务回滚

第一步&#xff0c;在springboot的启动类上开启事务&#xff0c;注解 EnableTransactionManagement 第二步&#xff1a;事务注解&#xff0c;回滚 Transactional(rollbackFor Exception.class) //Transactional和try catch捕获异常会让注解失效&#xff0c;所以&#xff1a; 第…

@EnableTransactionManagement

GetMapping("/saveData")ApiOperation("传感器数据上云-红外测温及气体")Transactional(rollbackFor Exception.class)public WebResult saveData(InfrareDataReqVo infrareDataReqVo){try {PigHeatEntity pigHeatEntitynew PigHeatEntity();pigHeatEntit…

根据经纬度显示地图轨迹

后端代码 public boolean saveCarGPSData(CarGPSReqVo carGPSReqVo) {Map<String,String> paramsnew HashMap<>(2);params.put("key",trsConfig.getCarGPS_key());params.put("coorType",carGPSReqVo.getCoorType());params.put("pageNu…

Linux vim 全选

全选&#xff08;高亮显示&#xff09;&#xff1a;按esc后&#xff0c;然后ggvG或者ggVG 全部复制&#xff1a;按esc后&#xff0c;然后ggyG 全部删除&#xff1a;按esc后&#xff0c;然后dG

两阶段聚合(局部聚合+全局聚合)

// 第一步&#xff0c;给RDD中的每个key都打上一个随机前缀。 JavaPairRDD<String, Long> randomPrefixRdd rdd.mapToPair(new PairFunction<Tuple2<Long,Long>, String, Long>() {private static final long serialVersionUID 1L;Overridepublic Tuple2&l…

java实现考勤机信息同步

/** * 更新传感器的用户信息 * * param sensorNumber * param attendanceEmployeeVos */ private synchronized void initializeAdd(String sensorNumber, List attendanceEmployeeVos) { if (attendanceEmployeeVos ! null && attendanceEmployeeVos.size() > 0) {…