您的位置:首页 > 数据库

sql子查询

2015-12-15 16:43 169 查看
--合同执行度(累计已审批/合同汇总金额)
--投资进度(合同汇总总额/批准概算投资额)
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: