当前位置:网站首页>G biaxial graph SQL script
G biaxial graph SQL script
2022-06-28 19:02:00 【South Lake Fishing Song】
# ----------------------- consumption -----------------------
-- temp_bi_df_m tb surface :
select
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
a.consume as consumption ,
b.consume as Month on month
-- round((a.consume-b.consume)/b.consume,2) as month_rate
from
(
select ym as d,consume
from (select ym,sum(consume) as consume -- According to :r_year,r_month grouping Become installation ym Field grouping
from temp_bi_df_m tb
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
where channel_kind in ($channel_kind) AND brand_name in ($brand_name) -- Change to variable sql
group by ym) t ) a
left join
(
-- Run right
select DATE_ADD(ym,INTERVAL 1 month ) as dd
,ym as original_month
,consume
from
(
select ym,sum(consume) as consume
from temp_bi_df_m tb
where channel_kind in ($channel_kind) AND brand_name in ($brand_name)
group by ym) t
) b
on a.d = b.dd;
-- bi_df_m tb surface :
select
-- substr(a.d,1,7) as month ,
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
round(a.consume) as consumption ,
-- b.dd,
-- b.original_month,
round(b.consume) as Month on month , -- as consume_last,
-- round((a.consume-b.consume)/b.consume,2) as Month on month growth rate -- month_rate
from
(
select DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d') as d,consume
from
(
select r_year,r_month,sum(consume) as consume
from grafana_bi.bi_df_m bdm
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
group by r_year,r_month) t
) a
left join
(
-- Run right
select DATE_ADD(DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d'),INTERVAL 1 month ) as dd
,DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d') as original_month
,consume
from
(
select r_year,r_month,sum(consume) as consume
from grafana_bi.bi_df_m bdm
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
group by r_year,r_month) t
) b
on a.d = b.dd;
# ----------------------- register -----------------------
-- temp_bi_df_m tb surface :
select
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
a.reg as Number of registrations ,
b.reg as Month on month
-- round((a.reg-b.reg)/b.reg,2) as month_rate
from
(
select ym as d,reg
from (select ym,sum(reg) as reg -- According to :r_year,r_month grouping Become installation ym Field grouping
from temp_bi_df_m tb
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
where channel_kind in ($channel_kind) AND brand_name in ($brand_name)
group by ym) t ) a
left join
(
-- Run right
select DATE_ADD(ym,INTERVAL 1 month ) as dd
,ym as original_month
,reg
from
(
select ym,sum(reg) as reg
from temp_bi_df_m tb
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
where channel_kind in ($channel_kind) AND brand_name in ($brand_name)
group by ym) t
) b
on a.d = b.dd;
-- bi_df_m tb surface :
select
-- substr(a.d,1,7) as month ,
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
round(a.reg) as Number of registrations ,
-- b.dd,
-- b.original_month,
round(b.reg) as Month on month , -- as reg_last,
round((a.reg-b.reg)/b.reg,2) as Month on month growth rate -- month_rate
from
(
select DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d') as d,reg
from
(
select r_year,r_month,sum(reg) as reg
from grafana_bi.bi_df_m bdm
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
group by r_year,r_month) t
) a
left join
(
-- Run right
select DATE_ADD(DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d'),INTERVAL 1 month ) as dd
,DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d') as original_month
,reg
from
(
select r_year,r_month,sum(reg) as reg
from grafana_bi.bi_df_m bdm
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
group by r_year,r_month) t
) b
on a.d = b.dd;
# ----------------------- Into gold -----------------------
-- temp_bi_df_m tb surface :
select
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
a.ent as Amount of deposit ,
b.ent as Month on month
-- round((a.ent-b.ent)/b.ent,2) as month_rate
from
(
select ym as d,ent
from (select ym,sum(ent) as ent -- According to :r_year,r_month grouping Become installation ym Field grouping
from temp_bi_df_m tb
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
where channel_kind in ($channel_kind) AND brand_name in ($brand_name)
group by ym) t ) a
left join
(
-- Run right
select DATE_ADD(ym,INTERVAL 1 month ) as dd
,ym as original_month
,ent
from
(
select ym,sum(ent) as ent
from temp_bi_df_m tb
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
where channel_kind in ($channel_kind) AND brand_name in ($brand_name)
group by ym) t
) b
on a.d = b.dd;
-- bi_df_m tb surface :
select
-- substr(a.d,1,7) as month ,
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
round(a.ent) as Amount of deposit ,
-- b.dd,
-- b.original_month,
round(b.ent) as Month on month , -- as ent_last,
round((a.ent-b.ent)/b.ent,2) as Month on month growth rate -- month_rate
from
(
select DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d') as d,ent
from
(
select r_year,r_month,sum(ent) as ent
from grafana_bi.bi_df_m bdm
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
group by r_year,r_month) t
) a
left join
(
-- Run right
select DATE_ADD(DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d'),INTERVAL 1 month ) as dd
,DATE_FORMAT(CONCAT(r_year,'-',r_month,'-01'),'%Y-%m-%d') as original_month
,ent
from
(
select r_year,r_month,sum(ent) as ent
from grafana_bi.bi_df_m bdm
-- where channel_kind = 'APP' AND brand_name = '2_bibgold'
group by r_year,r_month) t
) b
on a.d = b.dd;
边栏推荐
- 1 invalid import format(s) Postman Collection Format v1 is no longer supported and can not be import
- 180.1.连续登录N天(数据库)
- Shell unknown rollup 1
- 模块化操作
- An in-depth analysis of the election mechanism in kubernetes
- Cvpr2022 | Zhejiang University and ant group put forward a hierarchical residual multi granularity classification network based on label relation tree to model hierarchical knowledge among multi granu
- 上传文件列表(文件名重复加括号标识)
- Business layer modification - reverse modification based on the existing framework
- try except 添加辅助新列
- 应用实践 | 10 亿数据秒级关联,货拉拉基于 Apache Doris 的 OLAP 体系演进(附 PPT 下载)
猜你喜欢

pd.cut 区间参数设定之前后区别

Render function parsing

浅谈软件研发的复杂性与效能提升之道

Summary of the use of qobjectcleanuphandler in QT

1 invalid import format(s) Postman Collection Format v1 is no longer supported and can not be import

Steam education to break the barriers between disciplines

Servlet的使用手把手教学(一)

Memory leak

Mybayis之核心主件分析

业务层修改--根据现有框架的反推修改
随机推荐
Business layer modification - reverse modification based on the existing framework
19.2 container classification, array and vector container refinement
openGauss内核:SQL解析过程分析
上传文件列表(文件名重复加括号标识)
Opengauss kernel: analysis of SQL parsing process
About Significance Tests
Summary of the use of qobjectcleanuphandler in QT
Tensorboard Usage Summary
postgresql数据库docker
ANR Application Not Responding
rancher增加/删除node节点
grafana绘制走势图
Idea merge other branches into dev branch
Jenkins Pipeline 对Job参数的处理
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
shell读取Json文件的值
OOM out of memory 内存溢出
C# 41. Int to string
PostgreSQL database docker
A few lines of code can realize complex excel import and export. This tool class is really powerful!