性能瓶頸在1734表的重複掃描。算法
----------------------------------想進一步研究,繼續往下看------------------------------sql
1. 全部類似子查詢合併成一個(不單單是相同,如WBPJRQ,DBPJ,WBPJ字段),合併方法見下面代碼。數據庫
2. 若是僅是爲了驗證存在的話,能夠把join改成exist或者in。好比第一段腳本的1018表和1090表相連。oracle
在oracle和sqlserver中,join有3中算法,分別是循環迭代,組合,哈希。而這3種算法,都要進行所有匹配。MySQL沒有組合鏈接,只有兩種算法。sqlserver
而exist 和 in會根據統計信息,自動選擇用半鏈接算法,(not exist 和not in是反向半鏈接)。也就是說,假如a表與b表是1對多的,用join的話,會把全部記錄都比對一遍。而用exist或in,只要找到第一個就返回,再也不向下掃描。性能
3. 第一段和第三段能夠用or合併到一塊兒。合併後代碼長度減小了一半,可是性能變的更差。優化
由於or有時候會破壞索引(不是必定會破壞,可是咱們這個案例中確實破壞了)。解決辦法就是用union把or拆成幾個查詢。spa
4. 選擇掃屢次索引,仍是一次全表掃描,具體狀況具體分析。好比這個案例。code
1018表有71萬數據,而第一段代碼,返回的存在於1429的數據有1064條。第三段代碼,返回存在於1090的數據有6243條。orm
也就是說,若是用or合併,全表掃描,要掃71萬數據。而用索引union掃2次索引,只需掃約1064+6242,約1萬的數據。(全部的都是約數,還有掃中間節點等其餘開銷,可是對於這個案例,開銷能夠忽略)
而對於1734表的掃描,咱們須要的全部數據的父集合才4264的數據。因此對於1734的掃描,一次全表掃描遠比掃n次索引效率高。
在這個案例中,最終結果返回7000左右,若是忽略掉優化器自動優化,須要掃描的數據頁數約7000*子查詢個數*索引層級(由於每次掃描只拿一條數據,因此加上索引的層級開銷會成倍數放大。)
5.寫sql思惟要轉一下,儘可能批量操做。
由於數據庫的最小io單位是頁,一個頁有8k大。也就是說,就算只操做一個2進制位,最少也要掃8k的數據。
打個比方,如今有100條數據,放在10個數據頁裏面,索引有5層(可能不太合理)。要拿其中10條數據,批量操做,走索引最少掃5個數據頁(4個索引中間頁,一個數據頁),最多全表掃描10個數據頁。而單條操做,若是走索引5*10=50個數據頁(這仍是在索引是彙集索引的狀況下,若是是非彙集索引,再*2),不走索引10*10=100個數據頁。數據量越大,這個槓桿越高。因此有時候相同的業務邏輯,不一樣的代碼性能會差距很大。
|
|
------------------優化過腳本--------------
SELECT FXRH,
FXFL,
FXMC,
FXQC,
FXLXR,
FXRLXDH,
FXRCZ,
JBRXM,
JBRZJLX,
JBRZJHM,
JBRLXDH,
JBRCZ,
JBRQZWJM,
YLQZWJM,
FXZC,
JBYX,
WBPJ,
NBPJ,
ZHPJ,
SXED,
FXGJ,
ZCBZ,
DBPJ,
WBPJRQ
FROM (Select f34_1018 FXRH,
Case
When ob_object_name_1018 Like'%銀行%'Then
'2'
Else
'1'
EndAs FXFL,
substrb(nvl(f50_1018, ob_object_name_1018), 1, 32) FXMC,
ob_object_name_1018 FXQC,
substr((Select ob_object_name_1014
From wind.tb_object_1014 a
Wheresubstr(f29_1018, 6) = a.ob_object_id),
1,
16) FXLXR,
substrb(f36_1018, 1, 32) FXRLXDH,
substrb(f37_1018, 1, 32) FXRCZ,
'' JBRXM,
'' JBRZJLX,
'' JBRZJHM,
'' JBRLXDH,
'' JBRCZ,
'' JBRQZWJM,
'' YLQZWJM,
(SelectRound(f140_1853, 2)
From wind.tb_object_1853 a
Where f1_1853 = f34_1018
And f4_1853 = '合併報表'
And f2_1853 =
(SelectMax(b.f2_1853)
From wind.tb_object_1853 b
Where b.f1_1853 = f34_1018
And b.f4_1853 = '合併報表'
Andsubstr(b.f2_1853, 5, 4) = '1231')) FXZC,
'' JBYX,
decode(pj.jno,
'AAA',
'1',
'AAA-',
'2',
'AA+',
'3',
'AA',
'4',
'AA-',
'5',
'A+',
'P',
'A',
'6',
'A-',
'7',
'BBB+',
'Q',
'BBB',
'8',
'BBB-',
'9',
'BB+',
'A',
'BB',
'B',
'BB-',
'C',
'B+',
'D',
'B',
'E',
'B-',
'F',
'CCC',
'G',
'CC',
'H',
'C',
'I',
'D',
'J',
'A-1+',
'K',
'A-1',
'L',
'A-1-',
'M',
'A-2',
'N',
'A-3',
'O',
null) WBPJ,
'' NBPJ,
'' ZHPJ,
'' SXED,
decode(f3_1018,
'中國',
'CN',
'英國',
'GB',
'美國',
'US',
'澳大利亞',
'AU',
'百慕大羣島',
'BM',
'加拿大',
'CA',
'德國',
'DE',
'中國臺灣',
'TW',
'新加坡',
'SG',
'俄羅斯',
'RU',
'韓國',
'KR',
'日本',
'JP',
'以色列',
'IL',
'愛爾蘭',
'IE',
'中國香港',
'HK',
null) FXGJ,
'CNY' ZCBZ,
decode(pj.jno,
'AAA',
'1',
'AAA-',
'2',
'AA+',
'3',
'AA',
'4',
'AA-',
'5',
'A',
'6',
'BBB',
'7',
'BB',
'8',
'B',
'9',
null) DBPJ,
pj.rq WBPJRQ
From wind.tb_object_1018
leftjoin (Select a.f2_1734, Max(f4_1734) jno, max(f5_1734) rq
From wind.tb_object_1734 a
Where f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f2_1734 = a.f2_1734)
groupby a.f2_1734) pj
on f34_1018 = pj.f2_1734
whereexists
(select1
from wind.tb_object_1090
where f34_1018 = ob_revisions_1090
and f4_1090 In
('A', 'B', 'Z', 'Q', 'K', 'DQ', 'P', 'F', 'ZC'))
union
Select f34_1018,
case
when f41_1018 = 18THEN
'3'
ELSE
'1'
END,
case
when f41_1018 = 18THEN
substr(ob_object_name_1018,
1,
instr(ob_object_name_1018, '基金') + 1)
ELSE
ob_object_name_1018
END,
ob_object_name_1018,
substr((Select ob_object_name_1014
From wind.tb_object_1014 a
Wheresubstr(f29_1018, 6) = a.ob_object_id),
1,
16),
substrb(f36_1018, 1, 32),
substrb(f37_1018, 1, 32),
'',
'',
'',
'',
'',
'',
'',
to_number(''),
'' JBYX,
decode(pj.jno,
'AAA',
'1',
'AAA-',
'2',
'AA+',
'3',
'AA',
'4',
'AA-',
'5',
'A+',
'P',
'A',
'6',
'A-',
'7',
'BBB+',
'Q',
'BBB',
'8',
'BBB-',
'9',
'BB+',
'A',
'BB',
'B',
'BB-',
'C',
'B+',
'D',
'B',
'E',
'B-',
'F',
'CCC',
'G',
'CC',
'H',
'C',
'I',
'D',
'J',
'A-1+',
'K',
'A-1',
'L',
'A-1-',
'M',
'A-2',
'N',
'A-3',
'O',
null) WBPJ,
'' NBPJ,
'' ZHPJ,
'' SXED,
decode(f3_1018,
'中國',
'CN',
'英國',
'GB',
'美國',
'US',
'澳大利亞',
'AU',
'百慕大羣島',
'BM',
'加拿大',
'CA',
'德國',
'DE',
'中國臺灣',
'TW',
'新加坡',
'SG',
'俄羅斯',
'RU',
'韓國',
'KR',
'日本',
'JP',
'以色列',
'IL',
'愛爾蘭',
'IE',
'中國香港',
'HK',
null) FXGJ,
'CNY' ZCBZ,
decode(pj.jno,
'AAA',
'1',
'AAA-',
'2',
'AA+',
'3',
'AA',
'4',
'AA-',
'5',
'A',
'6',
'BBB',
'7',
'BB',
'8',
'B',
'9',
null) DBPJ,
pj.rq WBPJRQ
From wind.tb_object_1018
leftjoin (Select a.f2_1734, Max(f4_1734) jno, max(f5_1734) rq
From wind.tb_object_1734 a
Where f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f2_1734 = a.f2_1734)
groupby a.f2_1734) pj
on f34_1018 = pj.f2_1734
Where f34_1018 In (Select f12_1099 From wind.tb_object_1099)
union
Select f34_1018 FXRH,
Case
When ob_object_name_1018 Like'%銀行%'Then
'2'
Else
'1'
EndAs FXFL,
substrb(nvl(f50_1018, ob_object_name_1018), 1, 32) FXMC,
ob_object_name_1018 FXQC,
substr((Select ob_object_name_1014
From wind.tb_object_1014 a
Wheresubstr(f29_1018, 6) = a.ob_object_id),
1,
16) FXLXR,
substrb(f36_1018, 1, 32) FXRLXDH,
substrb(f37_1018, 1, 32) FXRCZ,
'' JBRXM,
'' JBRZJLX,
'' JBRZJHM,
'' JBRLXDH,
'' JBRCZ,
'' JBRQZWJM,
'' YLQZWJM,
(SelectRound(f140_1853, 2)
From wind.tb_object_1853 a
Where f1_1853 = f34_1018
And f4_1853 = '合併報表'
And f2_1853 =
(SelectMax(b.f2_1853)
From wind.tb_object_1853 b
Where b.f1_1853 = f34_1018
And b.f4_1853 = '合併報表'
Andsubstr(b.f2_1853, 5, 4) = '1231')) FXZC,
'' JBYX,
decode(pj.jno,
'AAA',
'1',
'AAA-',
'2',
'AA+',
'3',
'AA',
'4',
'AA-',
'5',
'A+',
'P',
'A',
'6',
'A-',
'7',
'BBB+',
'Q',
'BBB',
'8',
'BBB-',
'9',
'BB+',
'A',
'BB',
'B',
'BB-',
'C',
'B+',
'D',
'B',
'E',
'B-',
'F',
'CCC',
'G',
'CC',
'H',
'C',
'I',
'D',
'J',
'A-1+',
'K',
'A-1',
'L',
'A-1-',
'M',
'A-2',
'N',
'A-3',
'O',
null) WBPJ,
'' NBPJ,
'' ZHPJ,
'' SXED,
decode(f3_1018,
'中國',
'CN',
'英國',
'GB',
'美國',
'US',
'澳大利亞',
'AU',
'百慕大羣島',
'BM',
'加拿大',
'CA',
'德國',
'DE',
'中國臺灣',
'TW',
'新加坡',
'SG',
'俄羅斯',
'RU',
'韓國',
'KR',
'日本',
'JP',
'以色列',
'IL',
'愛爾蘭',
'IE',
'中國香港',
'HK',
null) FXGJ,
'CNY' ZCBZ,
decode(pj.jno,
'AAA',
'1',
'AAA-',
'2',
'AA+',
'3',
'AA',
'4',
'AA-',
'5',
'A',
'6',
'BBB',
'7',
'BB',
'8',
'B',
'9',
null) DBPJ,
pj.rq WBPJRQ
From wind.tb_object_1018
leftjoin (Select a.f2_1734, Max(f4_1734) jno, max(f5_1734) rq
From wind.tb_object_1734 a
Where f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f2_1734 = a.f2_1734)
groupby a.f2_1734) pj
on f34_1018 = pj.f2_1734
whereExists
(Select1From wind.tb_object_1429 Where f47_1429 = f34_1018))
OrderBy2, 3
----------------原腳本------------------------
SELECT FXRH,
FXFL,
FXMC,
FXQC,
FXLXR,
FXRLXDH,
FXRCZ,
JBRXM,
JBRZJLX,
JBRZJHM,
JBRLXDH,
JBRCZ,
JBRQZWJM,
YLQZWJM,
FXZC,
JBYX,
WBPJ,
NBPJ,
ZHPJ,
SXED,
FXGJ,
ZCBZ,
DBPJ,
WBPJRQ
FROM (SelectDistinct f34_1018 FXRH, --distinct去掉,union已經去重。distinct暗含排序操做,會佔用系統臨時表。
Case
When ob_object_name_1018 Like'%銀行%'Then
'2'
Else
'1'
EndAs FXFL,
substrb(nvl(f50_1018, ob_object_name_1018), 1, 32) FXMC,
ob_object_name_1018 FXQC,
substr((Select ob_object_name_1014
From wind.tb_object_1014 a
Wheresubstr(f29_1018, 6) = a.ob_object_id),
1,
16) FXLXR,
substrb(f36_1018, 1, 32) FXRLXDH,
substrb(f37_1018, 1, 32) FXRCZ,
'' JBRXM,
'' JBRZJLX,
'' JBRZJHM,
'' JBRLXDH,
'' JBRCZ,
'' JBRQZWJM,
'' YLQZWJM,
(SelectRound(f140_1853, 2)
From wind.tb_object_1853 a
Where f1_1853 = f34_1018
And f4_1853 = '合併報表'
And f2_1853 =
(SelectMax(b.f2_1853)
From wind.tb_object_1853 b
Where b.f1_1853 = a.f1_1853
And b.f4_1853 = '合併報表'
Andsubstr(b.f2_1853, 5, 4) = '1231')) FXZC,
'' JBYX,
Case
When (SelectMax(f4_1734) --如下全部對1734的掃描合併成一次
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AAA'Then
'1'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AAA-'Then
'2'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AA+'Then
'3'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA'Then
'4'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AA-'Then
'5'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A+'Then
'P'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A'Then
'6'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-'Then
'7'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'BBB+'Then
'Q'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'BBB'Then
'8'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'BBB-'Then
'9'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'BB+'Then
'A'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BB'Then
'B'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'BB-'Then
'C'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B+'Then
'D'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B'Then
'E'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B-'Then
'F'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'CCC'Then
'G'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'CC'Then
'H'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'C'Then
'I'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'D'Then
'J'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'A-1+'Then
'K'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'A-1'Then
'L'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'A-1-'Then
'M'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'A-2'Then
'N'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'A-3'Then
'O'
End WBPJ,
'' NBPJ,
'' ZHPJ,
'' SXED,
case
when f3_1018 = '中國'then
'CN'
when f3_1018 = '英國'then
'GB'
when f3_1018 = '美國'then
'US'
when f3_1018 = '澳大利亞'then
'AU'
when f3_1018 = '百慕大羣島'then
'BM'
when f3_1018 = '加拿大'then
'CA'
when f3_1018 = '德國'then
'DE'
when f3_1018 = '中國臺灣'then
'TW'
when f3_1018 = '新加坡'then
'SG'
when f3_1018 = '俄羅斯'then
'RU'
when f3_1018 = '韓國'then
'KR'
when f3_1018 = '日本'then
'JP'
when f3_1018 = '以色列'then
'IL'
when f3_1018 = '愛爾蘭'then
'IE'
when f3_1018 = '中國香港'then
'HK'
end FXGJ,
'CNY' ZCBZ,
Case
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AAA'Then
'1'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AAA-'Then
'2'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AA+'Then
'3'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA'Then
'4'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'AA-'Then
'5'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A'Then
'6'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) =
'BBB'Then
'7'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BB'Then
'8'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B'Then
'9'
End DBPJ,
(SelectMax(f5_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) WBPJRQ
From wind.tb_object_1090, wind.tb_object_1018
Where f4_1090 In ('A', 'B', 'Z', 'Q', 'K', 'DQ', 'P', 'F', 'ZC')
And f34_1018 = ob_revisions_1090
Union
Select f34_1018,
case
when f41_1018 = 18THEN
'3'
ELSE
'1'
END,
case
when f41_1018 = 18THEN
substr(ob_object_name_1018,
1,
instr(ob_object_name_1018, '基金') + 1)
ELSE
ob_object_name_1018
END,
ob_object_name_1018,
substr((Select ob_object_name_1014
From wind.tb_object_1014 a
Wheresubstr(f29_1018, 6) = a.ob_object_id),
1,
16),
substrb(f36_1018, 1, 32),
substrb(f37_1018, 1, 32),
'',
'',
'',
'',
'',
'',
'',
to_number(''),
'' JBYX,
Case
When (SelectMax(f4_1734) --同上
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AAA'Then
'1'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AAA-'Then
'2'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA+'Then
'3'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA'Then
'4'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA-'Then
'5'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A+'Then
'P'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A'Then
'6'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-'Then
'7'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BBB+'Then
'Q'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BBB'Then
'8'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BBB-'Then
'9'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BB+'Then
'A'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BB'Then
'B'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BB-'Then
'C'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B+'Then
'D'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B'Then
'E'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B-'Then
'F'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'CCC'Then
'G'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'CC'Then
'H'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'C'Then
'I'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'D'Then
'J'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-1+'Then
'K'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-1'Then
'L'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-1-'Then
'M'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-2'Then
'N'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A-3'Then
'O'
End WBPJ,
'' NBPJ,
'' ZHPJ,
'' SXED,
case
when f3_1018 = '中國'then
'CN'
when f3_1018 = '英國'then
'GB'
when f3_1018 = '美國'then
'US'
when f3_1018 = '澳大利亞'then
'AU'
when f3_1018 = '百慕大羣島'then
'BM'
when f3_1018 = '加拿大'then
'CA'
when f3_1018 = '德國'then
'DE'
when f3_1018 = '中國臺灣'then
'TW'
when f3_1018 = '新加坡'then
'SG'
when f3_1018 = '俄羅斯'then
'RU'
when f3_1018 = '韓國'then
'KR'
when f3_1018 = '日本'then
'JP'
when f3_1018 = '以色列'then
'IL'
when f3_1018 = '愛爾蘭'then
'IE'
when f3_1018 = '中國香港'then
'HK'
end FXGJ,
'CNY' ZCBZ,
Case
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AAA'Then
'1'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AAA-'Then
'2'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA+'Then
'3'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA'Then
'4'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA-'Then
'5'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A'Then
'6'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BBB'Then
'7'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'BB'Then
'8'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a,
wind.tb_object_0004,
wind.tb_object_1429
Where f47_1429 = f34_1018
And ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'B'Then
'9'
End DBPJ,
(SelectMax(f5_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 = (SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) WBPJRQ
From wind.tb_object_1018
Where f34_1018 In (Select f12_1099 From wind.tb_object_1099)
UNION
Select f34_1018,
Case
When ob_object_name_1018 Like'%銀行%'Then
'2'
Else
'1'
End,
substrb(nvl(f50_1018, ob_object_name_1018), 1, 32),
ob_object_name_1018,
substr((Select ob_object_name_1014
From wind.tb_object_1014 a
Wheresubstr(f29_1018, 6) = a.ob_object_id),
1,
16),
substrb(f36_1018, 1, 32),
substrb(f37_1018, 1, 32),
'',
'',
'',
'',
'',
'',
'',
(SelectRound(f140_1853, 2)
From wind.tb_object_1853 a
Where f1_1853 = f34_1018
And f4_1853 = '合併報表'
And f2_1853 =
(SelectMax(b.f2_1853)
From wind.tb_object_1853 b
Where b.f1_1853 = a.f1_1853
And b.f4_1853 = '合併報表'
Andsubstr(b.f2_1853, 5, 4) = '1231')) FXZC,
'' JBYX,
Case
When (SelectMax(f4_1734) ----同上
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AAA'Then
'1'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AAA-'Then
'2'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA+'Then
'3'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA'Then
'4'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'AA-'Then
'5'
When (SelectMax(f4_1734)
From wind.tb_object_1734 a, wind.tb_object_0004
Where ob_object_name_1018 = f1_0004
And f3_0004 = f2_1734
And f5_1734 =
(SelectMax(f5_1734)
From wind.tb_object_1734 b
Where b.f1_1734 = a.f1_1734)) = 'A+'