T-SQL中的比较实用技巧,处理数字为小数点后两位和判断类型显示不同文字

ALTER   PROCEDURE   [ dbo ] . [ sp_GetListPortfolio ]
@AccountId   uniqueidentifier
as
select  PortfolioId, 
       AccountId,
       PortfolioName,
       CreateDate,
       
CAST (TotalCost  as   decimal ( 38 , 2 ))  as  TotalCost,
       
CAST (TotalMarket  as   decimal ( 38 , 2 ))  as  TotalMarket,
       
CAST (EarnMoney  as   decimal ( 38 , 2 ))  as  EarnMoney,
       
CAST ((TotalMarket - TotalCost)  as   decimal ( 38 , 2 ))   as  EarnNow,
       
CAST (( case   when  TotalCost < 0.1   then   0   else   100 * (TotalMarket - TotalCost) / TotalCost  end as   decimal ( 38 , 2 ))  as  EarnNowPercent,
       (
case   when  type = 0   then  N ' 观察组合 '   else  N ' 实际组合 '   end as   [ Type ]
        
from  Portfolio  with  (nolock)
where  AccountId = @AccountId

你可能感兴趣的:(T-SQL中的比较实用技巧,处理数字为小数点后两位和判断类型显示不同文字)