How to use the autocorrelation method to calculate the same month on month ratio in 2021

CSDN Q & A 2022-05-15 04:46:49 阅读数:975

useautocorrelationmethodcalculatemonth

The data are as follows :
CREATE TABLE T_SALES (ID NUMBER(3),YEAR NUMBER(10),MONTH NUMBER(3),INCOME NUMBER(10,2));
INSERT INTO T_SALES VALUES('1',2020,'1','121.14');
INSERT INTO T_SALES VALUES('2',2020,'2','98.19');
INSERT INTO T_SALES VALUES('3',2020,'3','111.78');
INSERT INTO T_SALES VALUES('4',2020,'4','91.91');
INSERT INTO T_SALES VALUES('5',2020,'5','222.11');
INSERT INTO T_SALES VALUES('6',2020,'6','81.38');
INSERT INTO T_SALES VALUES('7',2020,'7','116.65');
INSERT INTO T_SALES VALUES('8',2020,'8','132.45');
INSERT INTO T_SALES VALUES('9',2020,'9','116.76');
INSERT INTO T_SALES VALUES('10',2020,'10','118.98');
INSERT INTO T_SALES VALUES('11',2020,'11','151.77');
INSERT INTO T_SALES VALUES('12',2020,'12','141.26');
INSERT INTO T_SALES VALUES('13',2021,'1','148.13');
INSERT INTO T_SALES VALUES('14',2021,'2','92.19');
INSERT INTO T_SALES VALUES('15',2021,'3','131.78');
INSERT INTO T_SALES VALUES('16',2021,'4','89.91');
INSERT INTO T_SALES VALUES('17',2021,'5','204.37');
INSERT INTO T_SALES VALUES('18',2021,'6','99.21');
INSERT INTO T_SALES VALUES('19',2021,'7','216.69');
INSERT INTO T_SALES VALUES('20',2021,'8','110.42');
INSERT INTO T_SALES VALUES('21',2021,'9','198.76');
INSERT INTO T_SALES VALUES('22',2021,'10','146.12');
INSERT INTO T_SALES VALUES('23',2021,'11','132.86');
COMMIT;




Take the answer :

Year on year
select b.*,(b.INCOME -a.INCOME )/a.INCOME
from T_SALES a join T_SALES b
on a.month=b.month and a.year=b.year-1

Chain ratio
select b.,(b.INCOME -a.INCOME )/a.INCOME
from T_SALES a join T_SALES b
on a.year
12+a.month=b.year*12+b.month-1


版权声明:本文为[CSDN Q & A]所创,转载请带上原文链接,感谢。 https://primo.wiki/2022/131/202205041702590027.html