当前位置:网站首页>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")
边栏推荐
- [yitianxue awk] regular matching
- uniapp支付之APP微信支付unicloud版(附源码)
- Discussion on JMeter operation principle
- golang基础 —— 切片和数组的区别
- 资源变现小程序开通流量主教程
- Tronapi-波场接口-PHP版本--附接口文档-基于ThinkPHP5封装-源码无加密-可二开-作者详细指导-2022年6月28日11:49:56
- The spiral matrix of the force buckle rotates together (you can understand it)
- RK356x U-Boot研究所(命令篇)3.3 env相关命令的用法
- All the abnormal knowledge you want is here
- Golang Basics - string and int, Int64 inter conversion
猜你喜欢
![[one day learning awk] array usage](/img/75/4333452142a3c7325e0712f3306985.png)
[one day learning awk] array usage

【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度

MATLAB小技巧(22)矩阵分析--逐步回归

黑马笔记---包装类,正则表达式,Arrays类

Determining the subject area of data warehouse construction

【C语言深度解剖】float变量在内存中存储原理&&指针变量与“零值”比较

Dark horse notes - common date API

RK356x U-Boot研究所(命令篇)3.2 help命令的用法

【OpenGL】OpenGL Examples

Flinksql customizes udatf to implement topn
随机推荐
Substrate 源码追新导读: Pallet Alliance 并入主线,
[yitianxue awk] regular matching
JS method of changing two-dimensional array to one-dimensional array
MySQL judges the calculation result and divides it by 100
Wechat launched the picture big bang function; Apple's self-developed 5g chip may have failed; Microsoft solves the bug that causes edge to stop responding | geek headlines
Dark horse notes - collection (common methods and traversal methods of collection)
ffmpeg 杂项
Hangzhou E-Commerce Research Institute: the official website (website) is the only form of private domain
排查问题的方法论(适用于任何多方合作中产生的问题排查)
After the market value evaporated by 65billion yuan, the "mask king" made steady medical treatment and focused on condoms
ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately
Qt读写Excel--QXlsx工作表显示/隐藏状态设置4
How to use AI technology to optimize the independent station customer service system? Listen to the experts!
Unity的脚本的基础语法(2)-Unity中记录时间
Questionnaire star questionnaire packet capturing analysis
Mysql根据经纬度查询半径多少以内的数据,画个圈圈查数据库
[one day learning awk] Fundamentals
JS 二维数组变一维数组的方法
Package tronapi wave field interface based on thinkphp5 PHP version -- interface document attached -20220627
Introduction to the new source code of substrat: fix the memory leak of the mission engine of beefy, and optimize the smart contract deletion queue