当前位置:网站首页>G 双轴图sql脚本
G 双轴图sql脚本
2022-06-28 18:39:00 【南湖渔歌】
# ----------------------- 消费 -----------------------
-- temp_bi_df_m tb 表:
select
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
a.consume as 消费,
b.consume as 环比上月
-- round((a.consume-b.consume)/b.consume,2) as month_rate
from
(
select ym as d,consume
from (select ym,sum(consume) as consume -- 将之前按照:r_year,r_month 分组 变成安装ym字段分组
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) -- 更改为变量sql
group by ym) t ) a
left join
(
-- 运行正确
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 表:
select
-- substr(a.d,1,7) as month ,
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
round(a.consume) as 消费,
-- b.dd,
-- b.original_month,
round(b.consume) as 环比上月, -- as consume_last,
-- round((a.consume-b.consume)/b.consume,2) as 环比增长率 -- 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
(
-- 运行正确
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;
# ----------------------- 注册 -----------------------
-- temp_bi_df_m tb 表:
select
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
a.reg as 注册数 ,
b.reg as 环比上月
-- round((a.reg-b.reg)/b.reg,2) as month_rate
from
(
select ym as d,reg
from (select ym,sum(reg) as reg -- 将之前按照:r_year,r_month 分组 变成安装ym字段分组
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
(
-- 运行正确
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 表:
select
-- substr(a.d,1,7) as month ,
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
round(a.reg) as 注册数,
-- b.dd,
-- b.original_month,
round(b.reg) as 环比上月, -- as reg_last,
round((a.reg-b.reg)/b.reg,2) as 环比增长率 -- 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
(
-- 运行正确
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;
# ----------------------- 入金 -----------------------
-- temp_bi_df_m tb 表:
select
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
a.ent as 入金数 ,
b.ent as 环比上月
-- round((a.ent-b.ent)/b.ent,2) as month_rate
from
(
select ym as d,ent
from (select ym,sum(ent) as ent -- 将之前按照:r_year,r_month 分组 变成安装ym字段分组
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
(
-- 运行正确
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 表:
select
-- substr(a.d,1,7) as month ,
STR_TO_DATE(a.d,'%Y-%m-%d') as time,
round(a.ent) as 入金数,
-- b.dd,
-- b.original_month,
round(b.ent) as 环比上月, -- as ent_last,
round((a.ent-b.ent)/b.ent,2) as 环比增长率 -- 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
(
-- 运行正确
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;
边栏推荐
- OOM out of memory 内存溢出
- MongoDB系列之MongoDB工作原理简单介绍
- 【Unity3D】相机跟随
- 好用、强大的PDF 阅读软件综合评测:PDF Expert 、MarginNote、LiquidText、Notability、GoodNotes、Zotero
- devpi
- Mybayis之核心主件分析
- 618活动季——百数低代码平台特享折扣来临
- Understanding of closures
- Win 10创建一个gin框架的项目
- 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
猜你喜欢

Professor Michael Wooldridge of Oxford University: how the AI community views neural networks in the past 40 years

抗兔Dylight 488丨Abbkine通用型免疫荧光(IF)工具箱

POI Excel转换工具

Pipeline based hybrid rendering

About Significance Tests

About Critical Values

Understanding of closures

Analysis of the core components of mybayis

解析机器人主持教学的实践发展

SMARCA2抗体研究:Abnova SMARCA2 单克隆抗体方案
随机推荐
Modular operation
Analyzing the practical development of robot teaching
CVPR2022 | 浙大、蚂蚁集团提出基于标签关系树的层级残差多粒度分类网络,建模多粒度标签间的层级知识
Can I open an account today and buy shares today? Is it safe to open an account online?
About Statistical Distributions
声网 VQA:将实时互动中未知的视频画质用户主观体验变可知
3D rotatable particle matrix
About Covariance and Correlation(协方差和相关)
应用实践 | 10 亿数据秒级关联,货拉拉基于 Apache Doris 的 OLAP 体系演进(附 PPT 下载)
What are the design requirements for PCB layout and wiring?
async-validator. JS data verifier
内存抖动
业务层修改--根据现有框架的反推修改
Openfire 3.8.2集群配置
Lumiprobe非荧光炔烃研究丨DBCO NHS 酯
匿名函数变量问题
MongoDB系列之MongoDB工作原理简单介绍
180.1. Log in continuously for n days (database)
POI Excel转换工具
leetcode 1423. Maximum Points You Can Obtain from Cards(从牌中能得到的最大点数和)