标签:sel code 计算 upd eid weight eric color stat
/****** Script for SelectTopNRows command from SSMS ******/ SELECT [fdSequenceID] ,[fdInnerTime] ,[fdTime] ,[fdData] ,[fdState] ,[fdUpdateTime] ,[fdCreateTime] FROM [NewDBTest].[dbo].[tbDataMonthHG] WITH f AS ( SELECT ROW_NUMBER()OVER( partition by fdSequenceID ORDER BY fdTime) AS id, * FROM [NewDBTest].[dbo].[tbDataMonthHG] ) select t.*, fdRate=(cast(cast(100*((t.fdData/NULLif(d.fdData,0))-1) as numeric(25,10)) as varchar(50))+‘%‘ ) --小数变百分数 from f t left join f d on t.fdInnerTime = DateAdd(year,1,d.fdInnerTime) and t.fdSequenceID = d.fdSequenceID --同比增长 order by fdSequenceID,id asc
标签:sel code 计算 upd eid weight eric color stat
原文地址:http://www.cnblogs.com/laozhanghahaha/p/6888254.html