求一条 oracle数据库统计用的sql语句,如下图所示,请高手帮忙解答。
展开全部
select
investorid,
(sumprofits/(lastday+sumfundout-allProfits))*100% 投资收益率
from
(
select
investorid,
sum(profits) sumprofits, --该投资者所有交易日利润总和
sum(fundout) sumfundout, --该投资者所有交易日出金总和
(select quanyi from fund ff where ff.investorid=f.investorid and ff.tradingday=(select max(tradingday) from fund fff where fff.investorid=ff.investorid)) lastday,--最后交易日权益
(select sum(profits) from fund) allProfits --投资者所有交易日利润总和
from fund f
group by investorid
)
大概是这样,但是没有测试过。根据这个思路来吧
investorid,
(sumprofits/(lastday+sumfundout-allProfits))*100% 投资收益率
from
(
select
investorid,
sum(profits) sumprofits, --该投资者所有交易日利润总和
sum(fundout) sumfundout, --该投资者所有交易日出金总和
(select quanyi from fund ff where ff.investorid=f.investorid and ff.tradingday=(select max(tradingday) from fund fff where fff.investorid=ff.investorid)) lastday,--最后交易日权益
(select sum(profits) from fund) allProfits --投资者所有交易日利润总和
from fund f
group by investorid
)
大概是这样,但是没有测试过。根据这个思路来吧
2014-11-23
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询