|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 allen31820 于 2011/8/23 15:29 编辑
ALTER PROC fa_Q_ZJQD_lzb(@LoginDate DateTime,@LoginPeriod int,@zclb varchar(50)) AS
SELECT fa_Cards.sCardNum as 卡片编码, fa_Cards.sAssetNum 资产编码, fa_Cards.sAssetName 资产名称,
(CASE @LoginPeriod WHEN 1 THEN [dblMonthValue1] WHEN 2 THEN [dblMonthValue2] WHEN 3 THEN [dblMonthValue3] WHEN 4 THEN [dblMonthValue4] WHEN 5 THEN [dblMonthValue5] WHEN 6 THEN [dblMonthValue6] WHEN 7 THEN [dblMonthValue7] WHEN 8 THEN [dblMonthValue8] WHEN 9 THEN [dblMonthValue9] WHEN 10 THEN [dblMonthValue10] WHEN 11 THEN [dblMonthValue11] ELSE [dblMonthValue12] END) AS 原值,
100*(CASE @LoginPeriod WHEN 1 THEN [dblDeprRate1] WHEN 2 THEN [dblDeprRate2] WHEN 3 THEN [dblDeprRate3] WHEN 4 THEN [dblDeprRate4] WHEN 5 THEN [dblDeprRate5] WHEN 6 THEN [dblDeprRate6] WHEN 7 THEN [dblDeprRate7] WHEN 8 THEN [dblDeprRate8] WHEN 9 THEN [dblDeprRate9] WHEN 10 THEN [dblDeprRate10] WHEN 11 THEN [dblDeprRate11] ELSE [dblDeprRate12] END) as [月折旧率%],
(CASE @LoginPeriod WHEN 1 THEN [dblDepr1] WHEN 2 THEN [dblDepr2] WHEN 3 THEN [dblDepr3] WHEN 4 THEN [dblDepr4] WHEN 5 THEN [dblDepr5] WHEN 6 THEN [dblDepr6] WHEN 7 THEN [dblDepr7] WHEN 8 THEN [dblDepr8] WHEN 9 THEN [dblDepr9] WHEN 10 THEN [dblDepr10] WHEN 11 THEN [dblDepr11] ELSE [dblDepr12] END) AS 月折旧额,
(CASE WHEN [fa_Cards].[iDisposePeriod]=2 THEN [fa_Cards].[dblDecDeprT] ELSE (CASE @LoginPeriod WHEN 1 THEN [dblDeprT1] WHEN 2 THEN [dblDeprT2] WHEN 3 THEN [dblDeprT3] WHEN 4 THEN [dblDeprT4] WHEN 5 THEN [dblDeprT5] WHEN 6 THEN [dblDeprT6] WHEN 7 THEN [dblDeprT7] WHEN 8 THEN [dblDeprT8] WHEN 9 THEN [dblDeprT9] WHEN 10 THEN [dblDeprT10] WHEN 11 THEN [dblDeprT11] ELSE [dblDeprT12] END) END) AS 累计折旧,
--添加净值
(CASE @LoginPeriod WHEN 1 THEN [dblMonthValue1] WHEN 2 THEN [dblMonthValue2] WHEN 3 THEN [dblMonthValue3] WHEN 4 THEN [dblMonthValue4] WHEN 5 THEN [dblMonthValue5] WHEN 6 THEN [dblMonthValue6] WHEN 7 THEN [dblMonthValue7] WHEN 8 THEN [dblMonthValue8] WHEN 9 THEN [dblMonthValue9] WHEN 10 THEN [dblMonthValue10] WHEN 11 THEN [dblMonthValue11] ELSE [dblMonthValue12] END)
-(CASE WHEN [fa_Cards].[iDisposePeriod]=2 THEN [fa_Cards].[dblDecDeprT] ELSE (CASE @LoginPeriod WHEN 1 THEN [dblDeprT1] WHEN 2 THEN [dblDeprT2] WHEN 3 THEN [dblDeprT3] WHEN 4 THEN [dblDeprT4] WHEN 5 THEN [dblDeprT5] WHEN 6 THEN [dblDeprT6] WHEN 7 THEN [dblDeprT7] WHEN 8 THEN [dblDeprT8] WHEN 9 THEN [dblDeprT9] WHEN 10 THEN [dblDeprT10] WHEN 11 THEN [dblDeprT11] ELSE [dblDeprT12] END) END) AS 净值 ,
(CASE @LoginPeriod WHEN 1 THEN [dblPerDepr1] WHEN 2 THEN [dblPerDepr2] WHEN 3 THEN [dblPerDepr3] WHEN 4 THEN [dblPerDepr4] WHEN 5 THEN [dblPerDepr5] WHEN 6 THEN [dblPerDepr6] WHEN 7 THEN [dblPerDepr7] WHEN 8 THEN [dblPerDepr8] WHEN 9 THEN [dblPerDepr9] WHEN 10 THEN [dblPerDepr10] WHEN 11 THEN [dblPerDepr11] ELSE [dblPerDepr12] END) AS dblPerDepr_,
(CASE @LoginPeriod WHEN 1 THEN [dblWork1] WHEN 2 THEN [dblWork2] WHEN 3 THEN [dblWork3] WHEN 4 THEN [dblWork4] WHEN 5 THEN [dblWork5] WHEN 6 THEN [dblWork6] WHEN 7 THEN [dblWork7] WHEN 8 THEN [dblWork8] WHEN 9 THEN [dblWork9] WHEN 10 THEN [dblWork10] WHEN 11 THEN [dblWork11] ELSE [dblWork12] END) AS dblWork_,
(CASE @LoginPeriod WHEN 1 THEN [dblWorkT1] WHEN 2 THEN [dblWorkT2] WHEN 3 THEN [dblWorkT3] WHEN 4 THEN [dblWorkT4] WHEN 5 THEN [dblWorkT5] WHEN 6 THEN [dblWorkT6] WHEN 7 THEN [dblWorkT7] WHEN 8 THEN [dblWorkT8] WHEN 9 THEN [dblWorkT9] WHEN 10 THEN [dblWorkT10] WHEN 11 THEN [dblWorkT11] ELSE [dblWorkT12] END) AS dblWorkTotal_
FROM (fa_Cards LEFT JOIN fa_DeprTransactions ON fa_Cards.sCardNum = fa_DeprTransactions.sCardNum) LEFT JOIN fa_WorkLoad ON fa_Cards.sCardNum = fa_WorkLoad.sCardNum
--添加过滤变量
JOIN fa_AssetTypes on fa_Cards.stypenum=fa_AssetTypes.snum
WHERE ((((CASE @LoginPeriod WHEN 1 THEN [dblDepr1] WHEN 2 THEN [dblDepr2] WHEN 3 THEN [dblDepr3] WHEN 4 THEN [dblDepr4] WHEN 5 THEN [dblDepr5] WHEN 6 THEN [dblDepr6] WHEN 7 THEN [dblDepr7] WHEN 8 THEN [dblDepr8] WHEN 9 THEN [dblDepr9] WHEN 10 THEN [dblDepr10] WHEN 11 THEN [dblDepr11] ELSE [dblDepr12] END))>0))
AND fa_Cards.sCardID IN(SELECT Max(sCardID) FROM fa_Cards
WHERE (((fa_Cards.dInputDate)<=@LoginDate) AND ((fa_Cards.dTransDate)<=@LoginDate Or (fa_Cards.dTransDate) Is Null) AND ((fa_Cards.dDisposeDate)<=@LoginDate Or (fa_Cards.dDisposeDate) Is Null))
GROUP BY fa_Cards.sCardNum) and fa_AssetTypes.sname=@zclb
ORDER BY fa_Cards.sCardNum
在开打这个报表的时候如何给这些 @LoginDate ,@LoginPeriod ,@zclb 变量赋值呢?
|
|