亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 數據庫 > SQL Server > 正文

sql中參數過多利用變量替換參數的方法

2024-08-31 01:01:55
字體:
來源:轉載
供稿:網友
工作中遇到一個需求,需要非常多的參數,例如如下sql,

復制代碼 代碼如下:


select
ff.fundsc||'-'||ff.fundtzfs||'-'||ff.fundcjfl||'-'||ff.fundonefl||'-'||ff.fundtowfl catagory,
sf.scode,replace(sf.fund5,'型證券投資基金','')fund5,sf.fund4,sf.fund10,
(select to_date(tradedate,'yyyy-MM-dd') from sdc_fundnetassetvalue where scode=sf.scode and tradedate in
(select max(tradedate) from sdc_fundnetassetvalue where scode=sf.scode and to_date(tradedate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and tradedate<=20120801) and rownum<2) trdatedate,
(select unitvalue from sdc_fundnetassetvalue where scode=sf.scode and tradedate in
(select max(tradedate) from sdc_fundnetassetvalue where scode=sf.scode and to_date(tradedate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and tradedate<=20120801) and rownum<2) fejz,
(select accumulatedunitvalue from sdc_fundnetassetvalue where scode=sf.scode and tradedate in
(select max(tradedate) from sdc_fundnetassetvalue where scode=sf.scode and to_date(tradedate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and tradedate<=20120801) and rownum<2) feljjz,
(select f30004_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2) gqyzjzzzl,
(select f30006_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2) gqyyjzzzl,
decode((select f30007_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30007_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) gqsgyjzzzl,
row_number() over(partition by ff.fundsc||'-'||ff.fundtzfs||'-'||ff.fundcjfl||'-'||ff.fundonefl||'-'||ff.fundtowfl
order by decode((select f30007_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30007_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) desc) sgy,
decode((select f30008_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30008_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) gqbnjzzzl,
row_number() over(partition by ff.fundsc||'-'||ff.fundtzfs||'-'||ff.fundcjfl||'-'||ff.fundonefl||'-'||ff.fundtowfl
order by decode((select f30008_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30008_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) desc) bn,
decode((select F30017_30003 from si_fund_30003 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30003 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select F30017_30003 from si_fund_30003 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30003 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) jinnian,
row_number() over(partition by ff.fundsc||'-'||ff.fundtzfs||'-'||ff.fundcjfl||'-'||ff.fundonefl||'-'||ff.fundtowfl
order by decode((select F30017_30003 from si_fund_30003 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30003 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select F30017_30003 from si_fund_30003 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30003 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) desc) jn,
decode((select f30009_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30009_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) gqynjzzzl,
row_number() over(partition by ff.fundsc||'-'||ff.fundtzfs||'-'||ff.fundcjfl||'-'||ff.fundonefl||'-'||ff.fundtowfl
order by decode((select f30009_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30009_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) desc) gqyn,
decode((select f30010_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30010_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) gqlnjzzzl,
row_number() over(partition by ff.fundsc||'-'||ff.fundtzfs||'-'||ff.fundcjfl||'-'||ff.fundonefl||'-'||ff.fundtowfl
order by decode((select f30010_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30010_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) desc) gqln,
decode((select f30011_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),
null,'-',to_char((select f30011_30002 from si_fund_30002 where f_fundcode=sf.scode and f_type=0 and f_tradingdate in
(select max(f_tradingdate) from si_fund_30002 where f_fundcode=sf.scode and to_date(f_tradingdate,'yyyyMMdd')>=(to_date(20120801,'yyyyMMdd')-10) and f_tradingdate<=20120801) and rownum<2),'fm999999990.9999')) gqsnjzzzl

from
(select
b.scode,b.fund5,b.fund4,b.fund10
from
sdc_fundbase b left join sdc_security a on b.scode=a.scode and b.mktcode=a.mktcode and b.fund49=a.stype
where
b.scode in (select t.fundcode from fund_fundcategoryone t where (t.fundtzfs='開放式' or t.fundtzfs='封閉式') and t.fundonefl!='貨幣市場基金' and t.fundonefl!='交易類' )
and (a.enddate>=to_date(20120801,'yyyy-MM-dd') or a.enddate is null or a.enddate=to_date(19000101,'yyyy-MM-dd'))
and a.stype in (6,7) order by scode
) sf
left join fund_fundcategoryone ff on sf.scode = ff.fundcode and ff.fundonefl!='交易類'


非常復雜,不仔細介紹,此時需要將20120801處全部變成參數傳入,,只寫參數就得累死我,下面方法可以節省我的好多工作量,在最內部函數中修改select
b.scode,b.fund5,b.fund4,b.fund10,20120801 tdate
from
將20120801用tdate變量來代替,這樣傳入的參數就用tdate來表示就可以了。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
精品动漫一区二区| 欧美性20hd另类| 国产精品美女在线| 久久久久久com| 日韩电影大片中文字幕| 日韩风俗一区 二区| 欧美另类69精品久久久久9999| 精品夜色国产国偷在线| 欧美日韩一区二区免费视频| 国产盗摄xxxx视频xxx69| 亚洲一区免费网站| 精品无码久久久久久国产| 国产日韩欧美日韩| 国产精品久久久久国产a级| 国产精品视频地址| 国产精品白嫩美女在线观看| 97精品久久久中文字幕免费| 欧美极品少妇与黑人| 欧美自拍视频在线| 久久综合久久八八| 久久精品国产一区二区三区| 国产欧美亚洲视频| 亚洲国产精品久久91精品| 亚洲欧美三级在线| 97国产成人精品视频| 国产精品wwwwww| 欧美视频在线看| 日韩美女av在线免费观看| 亚洲第一中文字幕在线观看| 精品视频在线观看日韩| 一本色道久久综合狠狠躁篇的优点| 黑丝美女久久久| 日本精品性网站在线观看| 欧美激情精品久久久久| 国产精品久久久久秋霞鲁丝| 国产精品女人久久久久久| 日韩免费观看在线观看| 日韩在线观看免费网站| 国产精品久久久久久av福利软件| 91精品免费久久久久久久久| 国产精品露脸自拍| 久久久人成影片一区二区三区| 97国产精品久久| 亚洲精品国产综合久久| 91免费电影网站| 久久精品青青大伊人av| 欧美成aaa人片在线观看蜜臀| 亚洲一级黄色片| 成人在线视频网站| 国产精品久久久久久久久影视| 成人www视频在线观看| 国产精品免费观看在线| 国产精品直播网红| 色综合久久中文字幕综合网小说| 亚洲精品中文字幕有码专区| 国产一区二区欧美日韩| 亚洲成人免费在线视频| 亚洲国产一区自拍| 亚洲激情视频在线观看| 久久99青青精品免费观看| 亚洲天堂2020| 亚洲精品国产美女| 欧美黄色片在线观看| 国产一区二区视频在线观看| 九九久久综合网站| 91国偷自产一区二区三区的观看方式| 亚洲电影免费在线观看| 亚洲va久久久噜噜噜| 欧美激情乱人伦| 久久夜精品香蕉| 亚洲欧美国产精品va在线观看| 久久亚洲影音av资源网| 国产亚洲视频在线观看| 国产在线拍揄自揄视频不卡99| 亚洲а∨天堂久久精品喷水| 国产精品啪视频| 欧洲亚洲在线视频| 欧美一级免费视频| 激情亚洲一区二区三区四区| 亚洲综合在线做性| 97国产suv精品一区二区62| 一区二区三欧美| 久久影院中文字幕| 亚洲精品一区二区久| 韩国v欧美v日本v亚洲| 国产亚洲一区二区在线| 美女性感视频久久久| 亚洲人成网站在线播| 国产成人精品久久二区二区| 中文字幕成人精品久久不卡| 久久免费视频这里只有精品| 秋霞午夜一区二区| 日韩欧美在线视频日韩欧美在线视频| 欧美一区三区三区高中清蜜桃| 中文字幕国产日韩| 国产精品18久久久久久麻辣| 欧美成人中文字幕在线| 日韩中文字幕亚洲| 韩国福利视频一区| 亚洲精品一区二区在线| 亚洲精品黄网在线观看| 亚洲第一精品电影| 成人欧美一区二区三区黑人| 亚洲a在线观看| 久久这里有精品视频| 亚洲免费视频网站| 欧美体内谢she精2性欧美| 欧美一级片在线播放| 亚洲精品一区av在线播放| 欧美性资源免费| 亚洲欧美一区二区激情| 久久大大胆人体| 国模精品视频一区二区| 欧美在线日韩在线| 日韩av片免费在线观看| 久久成人在线视频| 日韩小视频网址| 久久免费精品视频| 成人黄色生活片| 97久久久免费福利网址| 日韩美女视频免费在线观看| 国产亚洲精品久久久久久| 中文字幕日韩欧美| 视频在线观看99| 亚洲国产精品资源| 欧美日韩精品在线| 91精品久久久久久久久中文字幕| 欧美激情一二区| 欧美日韩亚洲成人| 欧美国产日韩视频| 日韩暖暖在线视频| 琪琪第一精品导航| 欧美情侣性视频| 91亚洲永久免费精品| 午夜精品一区二区三区在线| 国产一区二区三区在线免费观看| 欧美极品少妇xxxxⅹ免费视频| 97久久久免费福利网址| 亚洲va久久久噜噜噜久久天堂| 成人精品aaaa网站| 91国产高清在线| 国产亚洲欧洲高清一区| 人人澡人人澡人人看欧美| 97超级碰碰人国产在线观看| 色综合老司机第九色激情| 热99精品里视频精品| 91chinesevideo永久地址| 国产精品h片在线播放| 欧美专区在线视频| 国产精品电影网站| 中文字幕在线国产精品| 国产极品精品在线观看| 8050国产精品久久久久久| 国产精品欧美久久久| 欧美午夜丰满在线18影院| 91亚洲国产成人久久精品网站| 成人h视频在线| 亚洲女人天堂网| 欧美黑人又粗大| 亚洲天堂男人天堂女人天堂| 91在线精品视频| 久久久久久尹人网香蕉| 国外成人在线播放| 国产一区二区黑人欧美xxxx|