码迷,mamicode.com
首页 > 数据库 > 详细

sql子查询

时间:2015-12-15 16:49:53      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:

--合同执行度(累计已审批/合同汇总金额)
--投资进度(合同汇总总额/批准概算投资额)
select a.*,cast(round((ljysp/( case  when xmze=0 then 1 else xmze end))*100,2) as numeric(5,2)) as htzxd
,cast(round((( case  when AP =0 then 0 else xmze/AP end))*100,2)   as   numeric(5,2)) as tzjd
,ROW_NUMBER() OVER (ORDER BY InfoId desc) AS RowIndex
 from (
select
*,ISNULL((select Sum(HeaderMoney) from AgileCorp_Fund_PayApply where ProjectCode=Fund_vProject.ProjectCode),0)as ljysp,
ISNULL(( select sum((case  when InitFactInputPrice>0 then InitFactInputPrice else ContractPrice end)) from AgileCorp_Fund_Contract where ProjectCode=Fund_vProject.ProjectCode),0)
as xmze
 from Fund_vProject
)a

sql子查询

标签:

原文地址:http://www.cnblogs.com/howie/p/5048727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!