34,837
社区成员




create proc myproc
@shtnum varchar
as
begin
select a.*,b.bal_matchCreate,b.bal_matchPrice,b.bal_WinLost,c.cancelTime,c.msg,
( case when b.shtNum is not null then '平倉'
when c.shtNum is not null then '取消'
else '未平倉' end) as stkStauts
from stk_shtUnBal a,stk_shtBal b,stk_shtCancel c
where a.shtNum*=b.shtNum and a.shtNum*=c.shtNum
and a.shtNum=@shtNum
end
select
t.*
from
(select
shtNum,
stkName,
dtimeCreate,
priceCreate,
create_User_id,
null as bal_matchCreate,
null as bal_matchPrice,
null as bal_WinLost,
null as cancelTime,
null as msg,
'未平仓' as stkStauts
from
stk_shtUnBal
union all
select
shtNum,
stkName,
dtimeCreate,
priceCreate,
create_User_id,
bal_matchCreate,
bal_matchPrice,
null as bal_WinLost,
null as cancelTime,
null as msg,
'平仓' as stkStauts
from
stk_shtBal
union all
select
shtNum,
stkName,
dtimeCreate,
priceCreate,
create_User_id,
null as bal_matchCreate,
null as bal_matchPrice,
null as bal_WinLost,
cancelTime,
msg,
'取消' as stkStauts
from
stk_shtCancel) t
where
t.shtNum='0001'