当前位置:网站首页>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 内存溢出
- Anonymous function variable problem
- Analysis of the core components of mybayis
- Can I open an account today and buy shares today? Is it safe to open an account online?
- Rxjs map, mergeMap 和 switchMap 的区别和联系
- 几行代码就能实现复杂的 Excel 导入导出,这个工具类真心强大!
- Chapter 2 processing files, cameras and GUI Cameo applications
- 新工作第一天
- 解析机器人主持教学的实践发展
- async-validator.js数据校验器
猜你喜欢

About Significance Tests

180.1. Log in continuously for n days (database)

Record an emotet Trojan horse handling case

声网 VQA:将实时互动中未知的视频画质用户主观体验变可知

PHP使用栈解决迷宫问题

Seata implementation of sharing JDBC distributed transaction

向上转型和向下转型

Memory leak

匿名函数this指向以及变量提升

Yixin Huachen: real estate enterprises want to grasp the opportunity of the times for digital transformation
随机推荐
安装nodejs环境
OpenHarmony—内核对象事件之源码详解
CVPR2022 | 浙大、蚂蚁集团提出基于标签关系树的层级残差多粒度分类网络,建模多粒度标签间的层级知识
Business layer modification - reverse modification based on the existing framework
泰山OFFICE技术讲座:WORD奇怪的字体高度
微博评论的高性能高可用计算架构方案
BioVendor游离轻链(κ和λ)Elisa 试剂盒检测步骤
微软独家付费功能,也被完美解锁了
原生实现.NET5.0+ 自定义日志
leetcode 1647. Minimum deletions to make character frequencies unique
Anonymous function variable problem
devpi
中金财富开户安全吗?开过中金财富的讲一下
ANR Application Not Responding
Opencv中使用Tracker实现物体跟踪
内存泄露
打破学科之间壁垒的STEAM教育
OOM out of memory 内存溢出
Object tracking using tracker in opencv
数字化转型的1个目标,3大领域,6大因素和9个环节