当前位置:网站首页>2022-06-23 sail soft part formula and SQL generation (month and quarter retrieval)
2022-06-23 sail soft part formula and SQL generation (month and quarter retrieval)
2022-06-30 12:59:00 【Play with pigs】
The following is the sail soft formula :
1. Get the current month and push it back to March , If it is 8 month , get “9-11 month ” word
if($DATA_MONTH_BOX<10,($DATA_MONTH_BOX+1)+'-'+($DATA_MONTH_BOX+3)+' month ',
if($DATA_MONTH_BOX=10,$DATA_YEAR_BOX+' year 11 month -'+$NEXT_YEAR+' year 1 month ',
if($DATA_MONTH_BOX=11,$DATA_YEAR_BOX+' year 12 month -'+$NEXT_YEAR+' year 2 month ',
if($DATA_MONTH_BOX=12,$NEXT_YEAR+' year 1-3 month ',''))))
One month after obtaining , As the current 8 month , get "9 month ", At present, it is 12 month , get “+1 year 1 month ”
IF($DATA_MONTH_BOX<12,($DATA_MONTH_BOX+1)+' month ',
if($DATA_MONTH_BOX=12,$NEXT_YEAR+' year 1 month ',''))
Two months after acquisition
IF($DATA_MONTH_BOX<11,($DATA_MONTH_BOX+2)+' month ',
if($DATA_MONTH_BOX=11,$NEXT_YEAR+' year 1 month ',
IF($DATA_MONTH_BOX=12,$NEXT_YEAR+' year 2 month ','')))
Three months after acquisition
IF($DATA_MONTH_BOX<10,($DATA_MONTH_BOX+3)+' month ',
if($DATA_MONTH_BOX=10,$NEXT_YEAR+' year 1 month ',
IF($DATA_MONTH_BOX=11,$NEXT_YEAR+' year 2 month ',
IF($DATA_MONTH_BOX=12,$NEXT_YEAR+' year 3 month ',''))))
2. get 1- Last month , The current month is 1 When the month , get “ last year 1-12 month ”
if($ month != 1 && $ month != 2, $ month + ' Monthly proportion 1-' + ($ month - 1) + ' month ', if($ month = 1, $ month + ' The monthly proportion is higher than that of last year 1-12 month ', '2 Monthly proportion 1 month '))
sql Statement example :
sum(case when t.data_year='${ last year }' and t.data_month='${ month }' then t.num else 0 end ) as Manufacturer in the same month ,
${
if( month =='2',"sum(case when t.data_year='"+ year +"' and t.data_month='1' then t.num else 0 end ) as manufacturer 1 Accumulated last month ,","")}
${
if( month =='1',"sum(case when t.data_year='"+ last year +"' then t.num else 0 end ) as manufacturer 1 Accumulated last month ,","")}
${
if( month !='1' && month !='2',"sum(case when t.data_year='"+ year +"' and t.data_month<="+( month -1)+" then t.num else 0 end ) as manufacturer 1 Accumulated last month ,","")}
3. Get the current quarter
if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1) + ' quarter '
sql Statement example :
Set the control to ${ Current quarter _s}=if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1)
sum(case when t.data_year='${ year }' and (t.data_month>=(1+3*(${ Current quarter _s}-1)) and t.data_month<=(${ Current quarter _s}*3)) then t.num else 0 end ) as Quarterly sales volume of the manufacturer ,
When the data type is t.yue1 This kind of time
JOINARRAY(RANGE(if($ month %3=0,$ month /3-1,Int($ month /3))*3+1,if($ month %3=0,$ month /3-1,Int($ month /3))*3+3,1),"+t.yue")
4. get 1- The current quarter
'1-' + if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1) + ' quarter '
sql Statement example :
sum(case when t.data_year='${ year }' and t.data_month<=(${ Current quarter _s}*3) then t.num else 0 end ) as The manufacturer's quarterly accumulation ,
sum(case when t.data_year='${ last year }' and t.data_month<=(${ Current quarter _s}*3) then t.num else 0 end ) as The manufacturer has accumulated in the same quarter ,
5. get 1- Last quarter , The current quarter is 1 when , get “ last year 1-4 quarter ”, The example here is “ Proportion in the current quarter 1- Last quarter ”
if(if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1)!='1',if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1) + ' Quarterly proportion 1-' + (if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1) - 1) + ' season ','1 Quarter to quarter ratio last year 1-4 quarter ')
sql Statement example :
${
if( Current quarter _s!='1',
"sum(case when t.data_year='"+ year +"' and (t.data_month>=1 and t.data_month<="+(( Current quarter _s-1)*3)+") then t.num else 0 end ) as manufacturer 1 Accumulated in the last quarter ,",
"sum(case when t.data_year='"+ last year +"' then t.num else 0 end ) as manufacturer 1 Accumulated in the last quarter ,")}
When the data of a year in the database is placed in one piece :
IF(
if($ month % 3 = 0, $ month / 3, Int($ month / 3) + 1)!='1',
JOINARRAY(
RANGE(
(if($ month %3=0,$ month /3-1,Int($ month /3))-1)*3+1,
(if($ month %3=0,$ month /3-1,Int($ month /3))-1)*3+3,
1
)
,"+t.yue"
),
'10+t.yue11+t.yue12'
)
6. Get the current quarter , As the current 3 month , get “1 quarter ”
if($ month %3=0,$ month /3,Int($ month /3)+1)
sql Statement example :
Get the monthly calculation of quarterly accumulation sql, If the current month is 4 month , get 1-2 Quarter i.e 1-6 The cumulative number of months in the month sql
sum(case when t.data_year='${ year }' and (t.data_month>=(1+3*(${ Current quarter _s}-1)) and t.data_month<=(${ Current quarter _s}*3)) then t.num else 0 end ) as Quarterly sales volume of the manufacturer ,
If the sales data of one year is put in one piece of data :
JOINARRAY(RANGE(1,if($ month %3=0,$ month /3-1,Int($ month /3))*3+3,1),"+t.yue")
边栏推荐
- Flinksql customizes udatf to implement topn
- When MySQL judges that the execution condition is null, it returns 0. Correct parameter count in the call to native function 'isnull',
- ABAP工具箱 V1.0(附实现思路)
- Postman génère automatiquement des fragments de code Curl
- Machine learning notes - Introduction to autocorrelation and partial autocorrelation
- Efficient elliptic curve point addition and multiplication in scrypt
- 黑马笔记---集合(Collection的常用方法与遍历方式)
- Package based on thinkphp5 -tronapi- wave field interface - source code without encryption - can be opened twice - interface document attached - detailed guidance of the author - June 30, 2022 08:45:2
- 【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度
- [learn awk in one day] operator
猜你喜欢

黑马笔记---List系列集合与泛型
![[MySQL] MySQL installation and configuration](/img/82/8500949734e57e6a1047c4e838f625.png)
[MySQL] MySQL installation and configuration

Postman génère automatiquement des fragments de code Curl

深度长文探讨Join运算的简化和提速

rpm2rpm 打包步骤
![[qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external](/img/ca/9065325ce8882d95fb24c82fb62abc.png)
[qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external

【驚了】迅雷下載速度竟然比不上虛擬機中的下載速度

Idea 2021.3 golang error: rning: undefined behavior version of delve is too old for go version 1.18

Derivation of Park transformation formula for motor control

Dark horse notes -- wrapper class, regular expression, arrays class
随机推荐
All the abnormal knowledge you want is here
Golang Basics - string and int, Int64 inter conversion
全面解析免费及收费SSH工具的基本特性和总结
微信小程序报错:TypeError: Cannot read property ‘setData‘ of undefined
机器学习笔记 - 自相关和偏自相关简介
Flink SQL console, group not recognized_ Concat function?
FlinkSQL自定义UDAF使用的三种方式
Dataworks synchronizes maxcomputer to sqlserver. Chinese characters become garbled. How can I solve it
The spiral matrix of the force buckle rotates together (you can understand it)
Substrate 源码追新导读: 波卡系波卡权重计算全面更新, Governance 2.0 版本的优化和调整
[one day learning awk] Fundamentals
Qt中的数据库使用
Today in history: Microsoft acquires PowerPoint developers; SGI and MIPS merge
STM32 移植 RT-Thread 标准版的 FinSH 组件
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (II)
杭州电子商务研究院:官网(网站)是私域的唯一形态
ABAP工具箱 V1.0(附实现思路)
Qt中的事件处理
MATLAB小技巧(22)矩阵分析--逐步回归
ECDSA signature verification in crypt