股票大盘-SQL课程设计

股票大盘-SQL课程设计

ID:42650470

大小:135.44 KB

页数:9页

时间:2019-09-19

股票大盘-SQL课程设计_第1页
股票大盘-SQL课程设计_第2页
股票大盘-SQL课程设计_第3页
股票大盘-SQL课程设计_第4页
股票大盘-SQL课程设计_第5页
资源描述:

《股票大盘-SQL课程设计》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、setnocountonusestockgocreatetable月末收盘(口期datetimenull,收盘numeric(12,2)null)godeclare@ynchar(12),@yminnchar(12),Oymaxnchar(12)select0ymin=year(min(UWJ))from大盘select0ymax=year(max(HMH))from大盘declare@mintset0m=lset0y=0yminwhile@y<=@ymAxbeginwhile@m<=12begininsertinto月末U攵盘select日期,收盘from大盘wh

2、ere日期=(selectmax(日期)from大盘where(year(日期)=@yandmonth(日期)=@m))setendset@m=lset@y=@y+lendusestockgo一declare@日期datetime,@收盘numeric(12,2)了@副口期datetime,@副收盘numeric(12,2)declare@cint,@cointdeclare@rfloat,@sumfloatset@sum=0set@co=0set0r=lset0c=ldeclaremp_cursorcursorlocalstaticforselectH期,收盘fr

3、om月末收盘openmp_cursorfetchfirstfrommp_cursorinto@Fl期,@4攵盘fetchrelative1frommp_cursorinto@副日期,@副收盘set@r=@副收盘收盘set@co=@co+lset0c=0c+lwhile(@@fetch_status=Oand@c<=12)beginif0r>Oset@sum=@sum+@rfetchrelative11frommp_cursorinto@日期/@斗攵盘fetchrelative1frommp_cursorinto@副日期畐U收盘beginwhilefetch_stat

4、us=Oand@r>0and0c<=12)beginset@r=@副收盘收盘set@sum=@sum+@rset@co=0co+lfetchrelative11frommp_cursorinto@口期/攵盘fetchrelative1frommp_cursorinto@畐iJD期/@副4攵盘endif0r>Obeginprint'第'+C3St(@casvarchmr(12))+'月必盈利,平均盈利:1+cast(@sum/@coasvarchar(12))set@sum=0set@co=lendendfetchabsolute@cfrommp_cursorinto

5、@口期‘@4攵盘set@c=@c+lfetchabsolute@cfrommp_cursorinto@副日期/@副收盘set@r=@副收盘收盘endclosemp_cursordeallocatemp_cursorsetnocountonusestockgocreatetable月末收盘(口期datetimenull,收盘numeric(12,2)null)godeclare@ynchar(12),@yminnchar(12),Oymaxnchar(12)select0ymin=year(min(UWJ))from大盘select0ymax=year(max(HMH

6、))from大盘declare@mintset0m=lset0y=0yminwhile@y<=@ymmx/*年的循坏*/beginwhile@m<=12/*刀的循环★/begininsertinto月末收盘/*将每年的每月的最后一日收盘成交额insert入一张新表里*7select日期,收盘from大盘where日期=(selectmax(Fl期)from大盘where(year(日期)=@yandmonth(tl期)=@m))setendset@m=l/*第二年的新的循坏月份重新重1月開始讀★/set0y=@y+lendusestockgodeclare@FI期d

7、atetime,@收盘numeric(12,2)‘@副

8、~

9、期datetime,0副收盘numeric(12,2)declare@cint,@coint/*@c>@co都是计数器,@c用于输出第几个月,用于求平均数*/declare@rfloat,@sumfloat/*@匕用于计算前后个月收盘额的差额,0sum用于统计每年增长的增长额*/set@sum=0set0co=Oset0r=lset0c=ldeclaremp_cursorcursorlocalstatic/*全局游标★/forselectH期,收盘from月末收盘openmp_cursorfetchfi

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。