博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
存储过程--InOut
阅读量:4986 次
发布时间:2019-06-12

本文共 1756 字,大约阅读时间需要 5 分钟。

1. 存储过程名称:p_t_tradinglist

2. 参数 

 

3. 过程:

   

BEGIN  #Routine body goes here...  set @row=0;  select    @row:=@row+1 as '序号',   DATE_FORMAT(a.llcurtime,'%Y-%m-%d %T') as '成交时间', if (b.exchange='SHFE','上期所',    if(b.exchange='DCE', '大商所', if(b.exchange='CZCE', '郑商所', 'XXX'))) as '交易所',    b.goodname as '商品', a.contractid as '合约', if(a.direct='50','买', if(a.direct='51','卖','XXX')) as '买/卖',    a.price as '成交价', sum(a.share) as '手数',   if(a.flag=48,'开仓',(if(a.flag='51','平今', if(a.flag='52','平昨','XXX')))) as '开/平', -a.commission as '手续费',    a.orderid, d.price1 as '开仓价', a.price as '平仓价', c.lastPrices  as '结算价', e.vol_muliple,a.flag,      if(a.flag='48','', if(a.flag='51',(sum(a.share*a.price)/sum(a.share)-d.price1),(sum(a.share*a.price)/sum(a.share)-c.lastPrices))*if(direct='50',-1,1)*a.share*e.vol_muliple) as '平仓盈亏'   #,a.innerorderid   from hd_position_operator a      left JOIN hdmarket_monitor.t_good_instrument b on a.contractid = b.instrumentid      left join (select open_day, last_day from hd_trading_date)f on f.open_day = a.lltradedate     LEFT JOIN (select open_day, instrument, lastPrices from hd_settle_price)c             on b.instrumentid = c.instrument and c.open_day = f.last_day     LEFT JOIN (select orderid, sum(price*share)/sum(share) as price1 from hd_position_operator where flag = '48' and errorcode = '64'                group by orderid)d on a.orderid = d.orderid     left join (select contractid, vol_muliple from hd_contract_parm group by contractid)e on a.contractid = e.contractid   where a.serid like i_serid and a.lltradedate = i_tradingdate and a.errorcode = '64' group by a.innerorderid    order by a.llcurtime; END

 

4. 执行过程:

   call p_t_tradinglist('%110112%','20180530')

 

转载于:https://www.cnblogs.com/bruce-he/p/9134686.html

你可能感兴趣的文章
SQL SERVER 如何处理带字母的自增列--【叶子】
查看>>
使用DocFX生成文档
查看>>
AssemblyInfo.cs文件的作用
查看>>
android之PackageManager简单介绍
查看>>
GitLab备份与恢复
查看>>
20155307《网络对抗》免杀原理与实践
查看>>
《Android开发卷——自定义日期选择器(三)》
查看>>
游里工夫独造微一一小平邦彦传
查看>>
HTML5 JSON ( tuple => Object => JSON => Object=> Elements_of_tuple )
查看>>
layui中的html怎样接收后台的值,layui框架与SSM前后台交互的方法
查看>>
Skulpt在线模拟运行Python工具
查看>>
287.软件测试概述
查看>>
297.白盒测试
查看>>
新闻客户端的突破与创新
查看>>
网络通信引擎ICE的使用
查看>>
js滚动事件实现滚动触底加载
查看>>
(十)、iptables进行转发使内网能上网
查看>>
python之路《八》装饰器
查看>>
maven 打包前 Junit 测试
查看>>
spring boot 添加druid
查看>>