
IF OBJECT_ID ('WVIEW0031_YYYY', 'U') IS NOT NULL DROP TABLE WVIEW0031_YYYY;
GO
CREATE TABLE WVIEW0031_YYYY
(
VPERIOD varchar(8) COLLATE Japanese_BIN NOT NULL
,VKEY1 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY2 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY3 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY4 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY5 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY6 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY7 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY8 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY9 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY10 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY11 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY12 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY13 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY14 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY15 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY16 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY17 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY18 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY19 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY20 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY21 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY22 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY23 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY24 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY25 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY26 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY27 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY28 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY29 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY30 varchar(60) COLLATE Japanese_BIN NOT NULL
,VD1 numeric(14, 2) NOT NULL
,VD2 numeric(14, 2) NOT NULL
,VD3 numeric(14, 2) NOT NULL
,VD4 numeric(14, 2) NOT NULL
,VD5 numeric(14, 2) NOT NULL
,VD6 numeric(14, 2) NOT NULL
,VD7 numeric(14, 2) NOT NULL
,VD8 numeric(14, 2) NOT NULL
,VD9 numeric(14, 2) NOT NULL
,VD10 numeric(14, 2) NOT NULL
,VD11 numeric(14, 2) NOT NULL
,VD12 numeric(14, 2) NOT NULL
,VD13 numeric(14, 2) NOT NULL
,VD14 numeric(14, 2) NOT NULL
,VD15 numeric(14, 2) NOT NULL
,VD16 numeric(14, 2) NOT NULL
,VD17 numeric(14, 2) NOT NULL
,VD18 numeric(14, 2) NOT NULL
,VD19 numeric(14, 2) NOT NULL
,VD20 numeric(14, 2) NOT NULL
,VD21 numeric(14, 2) NOT NULL
,VD22 numeric(14, 2) NOT NULL
,VD23 numeric(14, 2) NOT NULL
,VD24 numeric(14, 2) NOT NULL
,VD25 numeric(14, 2) NOT NULL
,VD26 numeric(14, 2) NOT NULL
,VD27 numeric(14, 2) NOT NULL
,VD28 numeric(14, 2) NOT NULL
,VD29 numeric(14, 2) NOT NULL
,VD30 numeric(14, 2) NOT NULL
)
GO
CREATE INDEX IDX_WVIEW0031_YYYY_1 ON WVIEW0031_YYYY(VPERIOD);
GO
INSERT INTO WVIEW0031_YYYY
SELECT 
B.EX_YYYY "VPERIOD",
A.KEY1 "VKEY1" ,
A.KEY2 "VKEY2" ,
A.KEY3 "VKEY3" ,
A.KEY4 "VKEY4" ,
A.KEY5 "VKEY5" ,
A.KEY6 "VKEY6" ,
A.KEY7 "VKEY7" ,
A.KEY8 "VKEY8" ,
A.KEY9 "VKEY9" ,
A.KEY10 "VKEY10" ,
A.KEY11 "VKEY11" ,
A.KEY12 "VKEY12" ,
A.KEY13 "VKEY13" ,
A.KEY14 "VKEY14" ,
A.KEY15 "VKEY15",
A.KEY16 "VKEY16" ,
A.KEY17 "VKEY17" ,
A.KEY18 "VKEY18" ,
A.KEY19 "VKEY19" ,
A.KEY20 "VKEY20" ,
A.KEY21 "VKEY21" ,
A.KEY22 "VKEY22" ,
A.KEY23 "VKEY23" ,
A.KEY24 "VKEY24" ,
A.KEY25 "VKEY25" ,
A.KEY26 "VKEY26" ,
A.KEY27 "VKEY27" ,
A.KEY28 "VKEY28" ,
A.KEY29 "VKEY29" ,
A.KEY30 "VKEY30",
SUM(A.D1) "VD1" ,
SUM(A.D2) "VD2" ,
SUM(A.D3) "VD3" ,
SUM(A.D4) "VD4" ,
SUM(A.D5) "VD5" ,
SUM(A.D6) "VD6" ,
SUM(A.D7) "VD7" ,
SUM(A.D8) "VD8" ,
SUM(A.D9) "VD9" ,
SUM(A.D10) "VD10" ,
SUM(A.D11) "VD11" ,
SUM(A.D12) "VD12" ,
SUM(A.D13) "VD13" ,
SUM(A.D14) "VD14" ,
SUM(A.D15) "VD15" ,
SUM(A.D16) "VD16" ,
SUM(A.D17) "VD17" ,
SUM(A.D18) "VD18" ,
SUM(A.D19) "VD19" ,
SUM(A.D20) "VD20" ,
SUM(A.D21) "VD21" ,
SUM(A.D22) "VD22" ,
SUM(A.D23) "VD23" ,
SUM(A.D24) "VD24" ,
SUM(A.D25) "VD25" ,
SUM(A.D26) "VD26" ,
SUM(A.D27) "VD27" ,
SUM(A.D28) "VD28" ,
SUM(A.D29) "VD29" ,
SUM(A.D30) "VD30"
FROM 
EX_DATA3 A, 
EX_DAY B
WHERE 
A.DATE1 = B.EX_DATE
GROUP BY 
B.EX_YYYY,
A.KEY1 ,
A.KEY2 ,
A.KEY3 ,
A.KEY4 ,
A.KEY5 ,
A.KEY6 ,
A.KEY7 ,
A.KEY8 ,
A.KEY9 ,
A.KEY10 ,
A.KEY11 ,
A.KEY12 ,
A.KEY13 ,
A.KEY14 ,
A.KEY15 ,
A.KEY16 ,
A.KEY17 ,
A.KEY18 ,
A.KEY19 ,
A.KEY20 ,
A.KEY21 ,
A.KEY22 ,
A.KEY23 ,
A.KEY24 ,
A.KEY25 ,
A.KEY26 ,
A.KEY27 ,
A.KEY28 ,
A.KEY29 ,
A.KEY30 
;
GO


IF OBJECT_ID ('WVIEW0031_HALFYEAR', 'U') IS NOT NULL DROP TABLE WVIEW0031_HALFYEAR;
GO
CREATE TABLE WVIEW0031_HALFYEAR
(
VPERIOD varchar(8) COLLATE Japanese_BIN NOT NULL
,VKEY1 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY2 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY3 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY4 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY5 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY6 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY7 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY8 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY9 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY10 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY11 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY12 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY13 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY14 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY15 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY16 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY17 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY18 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY19 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY20 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY21 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY22 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY23 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY24 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY25 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY26 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY27 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY28 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY29 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY30 varchar(60) COLLATE Japanese_BIN NOT NULL
,VD1 numeric(14, 2) NOT NULL
,VD2 numeric(14, 2) NOT NULL
,VD3 numeric(14, 2) NOT NULL
,VD4 numeric(14, 2) NOT NULL
,VD5 numeric(14, 2) NOT NULL
,VD6 numeric(14, 2) NOT NULL
,VD7 numeric(14, 2) NOT NULL
,VD8 numeric(14, 2) NOT NULL
,VD9 numeric(14, 2) NOT NULL
,VD10 numeric(14, 2) NOT NULL
,VD11 numeric(14, 2) NOT NULL
,VD12 numeric(14, 2) NOT NULL
,VD13 numeric(14, 2) NOT NULL
,VD14 numeric(14, 2) NOT NULL
,VD15 numeric(14, 2) NOT NULL
,VD16 numeric(14, 2) NOT NULL
,VD17 numeric(14, 2) NOT NULL
,VD18 numeric(14, 2) NOT NULL
,VD19 numeric(14, 2) NOT NULL
,VD20 numeric(14, 2) NOT NULL
,VD21 numeric(14, 2) NOT NULL
,VD22 numeric(14, 2) NOT NULL
,VD23 numeric(14, 2) NOT NULL
,VD24 numeric(14, 2) NOT NULL
,VD25 numeric(14, 2) NOT NULL
,VD26 numeric(14, 2) NOT NULL
,VD27 numeric(14, 2) NOT NULL
,VD28 numeric(14, 2) NOT NULL
,VD29 numeric(14, 2) NOT NULL
,VD30 numeric(14, 2) NOT NULL
)
GO
CREATE INDEX IDX_WVIEW0031_HALFYEAR_1 ON WVIEW0031_HALFYEAR(VPERIOD);
GO
INSERT INTO WVIEW0031_HALFYEAR
SELECT 
B.EX_HALFYEAR "VPERIOD",
A.KEY1 "VKEY1" ,
A.KEY2 "VKEY2" ,
A.KEY3 "VKEY3" ,
A.KEY4 "VKEY4" ,
A.KEY5 "VKEY5" ,
A.KEY6 "VKEY6" ,
A.KEY7 "VKEY7" ,
A.KEY8 "VKEY8" ,
A.KEY9 "VKEY9" ,
A.KEY10 "VKEY10" ,
A.KEY11 "VKEY11" ,
A.KEY12 "VKEY12" ,
A.KEY13 "VKEY13" ,
A.KEY14 "VKEY14" ,
A.KEY15 "VKEY15",
A.KEY16 "VKEY16" ,
A.KEY17 "VKEY17" ,
A.KEY18 "VKEY18" ,
A.KEY19 "VKEY19" ,
A.KEY20 "VKEY20" ,
A.KEY21 "VKEY21" ,
A.KEY22 "VKEY22" ,
A.KEY23 "VKEY23" ,
A.KEY24 "VKEY24" ,
A.KEY25 "VKEY25" ,
A.KEY26 "VKEY26" ,
A.KEY27 "VKEY27" ,
A.KEY28 "VKEY28" ,
A.KEY29 "VKEY29" ,
A.KEY30 "VKEY30",
SUM(A.D1) "VD1" ,
SUM(A.D2) "VD2" ,
SUM(A.D3) "VD3" ,
SUM(A.D4) "VD4" ,
SUM(A.D5) "VD5" ,
SUM(A.D6) "VD6" ,
SUM(A.D7) "VD7" ,
SUM(A.D8) "VD8" ,
SUM(A.D9) "VD9" ,
SUM(A.D10) "VD10" ,
SUM(A.D11) "VD11" ,
SUM(A.D12) "VD12" ,
SUM(A.D13) "VD13" ,
SUM(A.D14) "VD14" ,
SUM(A.D15) "VD15" ,
SUM(A.D16) "VD16" ,
SUM(A.D17) "VD17" ,
SUM(A.D18) "VD18" ,
SUM(A.D19) "VD19" ,
SUM(A.D20) "VD20" ,
SUM(A.D21) "VD21" ,
SUM(A.D22) "VD22" ,
SUM(A.D23) "VD23" ,
SUM(A.D24) "VD24" ,
SUM(A.D25) "VD25" ,
SUM(A.D26) "VD26" ,
SUM(A.D27) "VD27" ,
SUM(A.D28) "VD28" ,
SUM(A.D29) "VD29" ,
SUM(A.D30) "VD30"
FROM 
EX_DATA3 A, 
EX_DAY B
WHERE 
A.DATE1 = B.EX_DATE
GROUP BY 
B.EX_HALFYEAR,
A.KEY1 ,
A.KEY2 ,
A.KEY3 ,
A.KEY4 ,
A.KEY5 ,
A.KEY6 ,
A.KEY7 ,
A.KEY8 ,
A.KEY9 ,
A.KEY10 ,
A.KEY11 ,
A.KEY12 ,
A.KEY13 ,
A.KEY14 ,
A.KEY15 ,
A.KEY16 ,
A.KEY17 ,
A.KEY18 ,
A.KEY19 ,
A.KEY20 ,
A.KEY21 ,
A.KEY22 ,
A.KEY23 ,
A.KEY24 ,
A.KEY25 ,
A.KEY26 ,
A.KEY27 ,
A.KEY28 ,
A.KEY29 ,
A.KEY30 
;
GO


IF OBJECT_ID ('WVIEW0031_TERM', 'U') IS NOT NULL DROP TABLE WVIEW0031_TERM;
GO
CREATE TABLE WVIEW0031_TERM
(
VPERIOD varchar(8) COLLATE Japanese_BIN NOT NULL
,VKEY1 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY2 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY3 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY4 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY5 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY6 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY7 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY8 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY9 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY10 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY11 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY12 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY13 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY14 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY15 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY16 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY17 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY18 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY19 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY20 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY21 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY22 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY23 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY24 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY25 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY26 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY27 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY28 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY29 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY30 varchar(60) COLLATE Japanese_BIN NOT NULL
,VD1 numeric(14, 2) NOT NULL
,VD2 numeric(14, 2) NOT NULL
,VD3 numeric(14, 2) NOT NULL
,VD4 numeric(14, 2) NOT NULL
,VD5 numeric(14, 2) NOT NULL
,VD6 numeric(14, 2) NOT NULL
,VD7 numeric(14, 2) NOT NULL
,VD8 numeric(14, 2) NOT NULL
,VD9 numeric(14, 2) NOT NULL
,VD10 numeric(14, 2) NOT NULL
,VD11 numeric(14, 2) NOT NULL
,VD12 numeric(14, 2) NOT NULL
,VD13 numeric(14, 2) NOT NULL
,VD14 numeric(14, 2) NOT NULL
,VD15 numeric(14, 2) NOT NULL
,VD16 numeric(14, 2) NOT NULL
,VD17 numeric(14, 2) NOT NULL
,VD18 numeric(14, 2) NOT NULL
,VD19 numeric(14, 2) NOT NULL
,VD20 numeric(14, 2) NOT NULL
,VD21 numeric(14, 2) NOT NULL
,VD22 numeric(14, 2) NOT NULL
,VD23 numeric(14, 2) NOT NULL
,VD24 numeric(14, 2) NOT NULL
,VD25 numeric(14, 2) NOT NULL
,VD26 numeric(14, 2) NOT NULL
,VD27 numeric(14, 2) NOT NULL
,VD28 numeric(14, 2) NOT NULL
,VD29 numeric(14, 2) NOT NULL
,VD30 numeric(14, 2) NOT NULL
)
GO
CREATE INDEX IDX_WVIEW0031_TERM_1 ON WVIEW0031_TERM(VPERIOD);
GO
INSERT INTO WVIEW0031_TERM
SELECT 
B.EX_TERM "VPERIOD",
A.KEY1 "VKEY1" ,
A.KEY2 "VKEY2" ,
A.KEY3 "VKEY3" ,
A.KEY4 "VKEY4" ,
A.KEY5 "VKEY5" ,
A.KEY6 "VKEY6" ,
A.KEY7 "VKEY7" ,
A.KEY8 "VKEY8" ,
A.KEY9 "VKEY9" ,
A.KEY10 "VKEY10" ,
A.KEY11 "VKEY11" ,
A.KEY12 "VKEY12" ,
A.KEY13 "VKEY13" ,
A.KEY14 "VKEY14" ,
A.KEY15 "VKEY15",
A.KEY16 "VKEY16" ,
A.KEY17 "VKEY17" ,
A.KEY18 "VKEY18" ,
A.KEY19 "VKEY19" ,
A.KEY20 "VKEY20" ,
A.KEY21 "VKEY21" ,
A.KEY22 "VKEY22" ,
A.KEY23 "VKEY23" ,
A.KEY24 "VKEY24" ,
A.KEY25 "VKEY25" ,
A.KEY26 "VKEY26" ,
A.KEY27 "VKEY27" ,
A.KEY28 "VKEY28" ,
A.KEY29 "VKEY29" ,
A.KEY30 "VKEY30",
SUM(A.D1) "VD1" ,
SUM(A.D2) "VD2" ,
SUM(A.D3) "VD3" ,
SUM(A.D4) "VD4" ,
SUM(A.D5) "VD5" ,
SUM(A.D6) "VD6" ,
SUM(A.D7) "VD7" ,
SUM(A.D8) "VD8" ,
SUM(A.D9) "VD9" ,
SUM(A.D10) "VD10" ,
SUM(A.D11) "VD11" ,
SUM(A.D12) "VD12" ,
SUM(A.D13) "VD13" ,
SUM(A.D14) "VD14" ,
SUM(A.D15) "VD15" ,
SUM(A.D16) "VD16" ,
SUM(A.D17) "VD17" ,
SUM(A.D18) "VD18" ,
SUM(A.D19) "VD19" ,
SUM(A.D20) "VD20" ,
SUM(A.D21) "VD21" ,
SUM(A.D22) "VD22" ,
SUM(A.D23) "VD23" ,
SUM(A.D24) "VD24" ,
SUM(A.D25) "VD25" ,
SUM(A.D26) "VD26" ,
SUM(A.D27) "VD27" ,
SUM(A.D28) "VD28" ,
SUM(A.D29) "VD29" ,
SUM(A.D30) "VD30"
FROM 
EX_DATA3 A, 
EX_DAY B
WHERE 
A.DATE1 = B.EX_DATE
GROUP BY 
B.EX_TERM,
A.KEY1 ,
A.KEY2 ,
A.KEY3 ,
A.KEY4 ,
A.KEY5 ,
A.KEY6 ,
A.KEY7 ,
A.KEY8 ,
A.KEY9 ,
A.KEY10 ,
A.KEY11 ,
A.KEY12 ,
A.KEY13 ,
A.KEY14 ,
A.KEY15 ,
A.KEY16 ,
A.KEY17 ,
A.KEY18 ,
A.KEY19 ,
A.KEY20 ,
A.KEY21 ,
A.KEY22 ,
A.KEY23 ,
A.KEY24 ,
A.KEY25 ,
A.KEY26 ,
A.KEY27 ,
A.KEY28 ,
A.KEY29 ,
A.KEY30 
;
GO


IF OBJECT_ID ('WVIEW0031_YYYYMM', 'U') IS NOT NULL DROP TABLE WVIEW0031_YYYYMM;
GO
CREATE TABLE WVIEW0031_YYYYMM
(
VPERIOD varchar(8) COLLATE Japanese_BIN NOT NULL
,VKEY1 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY2 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY3 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY4 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY5 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY6 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY7 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY8 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY9 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY10 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY11 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY12 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY13 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY14 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY15 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY16 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY17 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY18 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY19 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY20 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY21 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY22 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY23 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY24 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY25 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY26 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY27 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY28 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY29 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY30 varchar(60) COLLATE Japanese_BIN NOT NULL
,VD1 numeric(14, 2) NOT NULL
,VD2 numeric(14, 2) NOT NULL
,VD3 numeric(14, 2) NOT NULL
,VD4 numeric(14, 2) NOT NULL
,VD5 numeric(14, 2) NOT NULL
,VD6 numeric(14, 2) NOT NULL
,VD7 numeric(14, 2) NOT NULL
,VD8 numeric(14, 2) NOT NULL
,VD9 numeric(14, 2) NOT NULL
,VD10 numeric(14, 2) NOT NULL
,VD11 numeric(14, 2) NOT NULL
,VD12 numeric(14, 2) NOT NULL
,VD13 numeric(14, 2) NOT NULL
,VD14 numeric(14, 2) NOT NULL
,VD15 numeric(14, 2) NOT NULL
,VD16 numeric(14, 2) NOT NULL
,VD17 numeric(14, 2) NOT NULL
,VD18 numeric(14, 2) NOT NULL
,VD19 numeric(14, 2) NOT NULL
,VD20 numeric(14, 2) NOT NULL
,VD21 numeric(14, 2) NOT NULL
,VD22 numeric(14, 2) NOT NULL
,VD23 numeric(14, 2) NOT NULL
,VD24 numeric(14, 2) NOT NULL
,VD25 numeric(14, 2) NOT NULL
,VD26 numeric(14, 2) NOT NULL
,VD27 numeric(14, 2) NOT NULL
,VD28 numeric(14, 2) NOT NULL
,VD29 numeric(14, 2) NOT NULL
,VD30 numeric(14, 2) NOT NULL
)
GO
CREATE INDEX IDX_WVIEW0031_YYYYMM_1 ON WVIEW0031_YYYYMM(VPERIOD);
GO
INSERT INTO WVIEW0031_YYYYMM
SELECT 
B.EX_YYYYMM "VPERIOD",
A.KEY1 "VKEY1" ,
A.KEY2 "VKEY2" ,
A.KEY3 "VKEY3" ,
A.KEY4 "VKEY4" ,
A.KEY5 "VKEY5" ,
A.KEY6 "VKEY6" ,
A.KEY7 "VKEY7" ,
A.KEY8 "VKEY8" ,
A.KEY9 "VKEY9" ,
A.KEY10 "VKEY10" ,
A.KEY11 "VKEY11" ,
A.KEY12 "VKEY12" ,
A.KEY13 "VKEY13" ,
A.KEY14 "VKEY14" ,
A.KEY15 "VKEY15",
A.KEY16 "VKEY16" ,
A.KEY17 "VKEY17" ,
A.KEY18 "VKEY18" ,
A.KEY19 "VKEY19" ,
A.KEY20 "VKEY20" ,
A.KEY21 "VKEY21" ,
A.KEY22 "VKEY22" ,
A.KEY23 "VKEY23" ,
A.KEY24 "VKEY24" ,
A.KEY25 "VKEY25" ,
A.KEY26 "VKEY26" ,
A.KEY27 "VKEY27" ,
A.KEY28 "VKEY28" ,
A.KEY29 "VKEY29" ,
A.KEY30 "VKEY30",
SUM(A.D1) "VD1" ,
SUM(A.D2) "VD2" ,
SUM(A.D3) "VD3" ,
SUM(A.D4) "VD4" ,
SUM(A.D5) "VD5" ,
SUM(A.D6) "VD6" ,
SUM(A.D7) "VD7" ,
SUM(A.D8) "VD8" ,
SUM(A.D9) "VD9" ,
SUM(A.D10) "VD10" ,
SUM(A.D11) "VD11" ,
SUM(A.D12) "VD12" ,
SUM(A.D13) "VD13" ,
SUM(A.D14) "VD14" ,
SUM(A.D15) "VD15" ,
SUM(A.D16) "VD16" ,
SUM(A.D17) "VD17" ,
SUM(A.D18) "VD18" ,
SUM(A.D19) "VD19" ,
SUM(A.D20) "VD20" ,
SUM(A.D21) "VD21" ,
SUM(A.D22) "VD22" ,
SUM(A.D23) "VD23" ,
SUM(A.D24) "VD24" ,
SUM(A.D25) "VD25" ,
SUM(A.D26) "VD26" ,
SUM(A.D27) "VD27" ,
SUM(A.D28) "VD28" ,
SUM(A.D29) "VD29" ,
SUM(A.D30) "VD30"
FROM 
EX_DATA3 A, 
EX_DAY B
WHERE 
A.DATE1 = B.EX_DATE
GROUP BY 
B.EX_YYYYMM,
A.KEY1 ,
A.KEY2 ,
A.KEY3 ,
A.KEY4 ,
A.KEY5 ,
A.KEY6 ,
A.KEY7 ,
A.KEY8 ,
A.KEY9 ,
A.KEY10 ,
A.KEY11 ,
A.KEY12 ,
A.KEY13 ,
A.KEY14 ,
A.KEY15 ,
A.KEY16 ,
A.KEY17 ,
A.KEY18 ,
A.KEY19 ,
A.KEY20 ,
A.KEY21 ,
A.KEY22 ,
A.KEY23 ,
A.KEY24 ,
A.KEY25 ,
A.KEY26 ,
A.KEY27 ,
A.KEY28 ,
A.KEY29 ,
A.KEY30 
;
GO


IF OBJECT_ID ('WVIEW0031_TENDAYS', 'U') IS NOT NULL DROP TABLE WVIEW0031_TENDAYS;
GO
CREATE TABLE WVIEW0031_TENDAYS
(
VPERIOD varchar(8) COLLATE Japanese_BIN NOT NULL
,VKEY1 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY2 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY3 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY4 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY5 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY6 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY7 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY8 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY9 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY10 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY11 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY12 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY13 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY14 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY15 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY16 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY17 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY18 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY19 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY20 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY21 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY22 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY23 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY24 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY25 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY26 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY27 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY28 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY29 varchar(60) COLLATE Japanese_BIN NOT NULL
,VKEY30 varchar(60) COLLATE Japanese_BIN NOT NULL
,VD1 numeric(14, 2) NOT NULL
,VD2 numeric(14, 2) NOT NULL
,VD3 numeric(14, 2) NOT NULL
,VD4 numeric(14, 2) NOT NULL
,VD5 numeric(14, 2) NOT NULL
,VD6 numeric(14, 2) NOT NULL
,VD7 numeric(14, 2) NOT NULL
,VD8 numeric(14, 2) NOT NULL
,VD9 numeric(14, 2) NOT NULL
,VD10 numeric(14, 2) NOT NULL
,VD11 numeric(14, 2) NOT NULL
,VD12 numeric(14, 2) NOT NULL
,VD13 numeric(14, 2) NOT NULL
,VD14 numeric(14, 2) NOT NULL
,VD15 numeric(14, 2) NOT NULL
,VD16 numeric(14, 2) NOT NULL
,VD17 numeric(14, 2) NOT NULL
,VD18 numeric(14, 2) NOT NULL
,VD19 numeric(14, 2) NOT NULL
,VD20 numeric(14, 2) NOT NULL
,VD21 numeric(14, 2) NOT NULL
,VD22 numeric(14, 2) NOT NULL
,VD23 numeric(14, 2) NOT NULL
,VD24 numeric(14, 2) NOT NULL
,VD25 numeric(14, 2) NOT NULL
,VD26 numeric(14, 2) NOT NULL
,VD27 numeric(14, 2) NOT NULL
,VD28 numeric(14, 2) NOT NULL
,VD29 numeric(14, 2) NOT NULL
,VD30 numeric(14, 2) NOT NULL
)
GO
CREATE INDEX IDX_WVIEW0031_TENDAYS_1 ON WVIEW0031_TENDAYS(VPERIOD);
GO
INSERT INTO WVIEW0031_TENDAYS
SELECT 
B.EX_TENDAYS "VPERIOD",
A.KEY1 "VKEY1" ,
A.KEY2 "VKEY2" ,
A.KEY3 "VKEY3" ,
A.KEY4 "VKEY4" ,
A.KEY5 "VKEY5" ,
A.KEY6 "VKEY6" ,
A.KEY7 "VKEY7" ,
A.KEY8 "VKEY8" ,
A.KEY9 "VKEY9" ,
A.KEY10 "VKEY10" ,
A.KEY11 "VKEY11" ,
A.KEY12 "VKEY12" ,
A.KEY13 "VKEY13" ,
A.KEY14 "VKEY14" ,
A.KEY15 "VKEY15",
A.KEY16 "VKEY16" ,
A.KEY17 "VKEY17" ,
A.KEY18 "VKEY18" ,
A.KEY19 "VKEY19" ,
A.KEY20 "VKEY20" ,
A.KEY21 "VKEY21" ,
A.KEY22 "VKEY22" ,
A.KEY23 "VKEY23" ,
A.KEY24 "VKEY24" ,
A.KEY25 "VKEY25" ,
A.KEY26 "VKEY26" ,
A.KEY27 "VKEY27" ,
A.KEY28 "VKEY28" ,
A.KEY29 "VKEY29" ,
A.KEY30 "VKEY30",
SUM(A.D1) "VD1" ,
SUM(A.D2) "VD2" ,
SUM(A.D3) "VD3" ,
SUM(A.D4) "VD4" ,
SUM(A.D5) "VD5" ,
SUM(A.D6) "VD6" ,
SUM(A.D7) "VD7" ,
SUM(A.D8) "VD8" ,
SUM(A.D9) "VD9" ,
SUM(A.D10) "VD10" ,
SUM(A.D11) "VD11" ,
SUM(A.D12) "VD12" ,
SUM(A.D13) "VD13" ,
SUM(A.D14) "VD14" ,
SUM(A.D15) "VD15" ,
SUM(A.D16) "VD16" ,
SUM(A.D17) "VD17" ,
SUM(A.D18) "VD18" ,
SUM(A.D19) "VD19" ,
SUM(A.D20) "VD20" ,
SUM(A.D21) "VD21" ,
SUM(A.D22) "VD22" ,
SUM(A.D23) "VD23" ,
SUM(A.D24) "VD24" ,
SUM(A.D25) "VD25" ,
SUM(A.D26) "VD26" ,
SUM(A.D27) "VD27" ,
SUM(A.D28) "VD28" ,
SUM(A.D29) "VD29" ,
SUM(A.D30) "VD30"
FROM 
EX_DATA3 A, 
EX_DAY B
WHERE 
A.DATE1 = B.EX_DATE
GROUP BY 
B.EX_TENDAYS,
A.KEY1 ,
A.KEY2 ,
A.KEY3 ,
A.KEY4 ,
A.KEY5 ,
A.KEY6 ,
A.KEY7 ,
A.KEY8 ,
A.KEY9 ,
A.KEY10 ,
A.KEY11 ,
A.KEY12 ,
A.KEY13 ,
A.KEY14 ,
A.KEY15 ,
A.KEY16 ,
A.KEY17 ,
A.KEY18 ,
A.KEY19 ,
A.KEY20 ,
A.KEY21 ,
A.KEY22 ,
A.KEY23 ,
A.KEY24 ,
A.KEY25 ,
A.KEY26 ,
A.KEY27 ,
A.KEY28 ,
A.KEY29 ,
A.KEY30 
;
GO


EXIT
