我有这张桌子:
ROW_GROUP COL_GROUP CLAIM_COUNT DENIAL_AMOUNT NOT MEDIC NEC/PRE-X October 2010 6 591.50 NOT MEDIC NEC/PRE-X November 2010 8 3154.48 DUPLICATE October 2010 39 7921.78 DUPLICATE November 2010 35 7484.17 REGISTRATION October 2010 56 10622.55 REGISTRATION November 2010 67 7820.69 TIMELY FILING September 2010 6 239.00 TIMELY FILING October 2010 67 8389.25 TIMELY FILING November 2010 6 51127.96
我需要能够将claim(或任何COL_GROUP字段)添加到此表中,并在claim_count和denial_amount中添加空值。 ROW_GROUP和COL_GROUP是动态生成的,所以我不能只更新字段,这必须在存储过程中完成。有人提到左外连接可能会为我创建这些空值,只是不确定如何。任何建议都会有所帮助。
建议在工作中使用同事的这个sql语句,但它似乎不起作用:
select #TREND.ROW_GROUP, DISTINCTTIME.COL_GROUP, #TREND.CLAIM_COUNT, #TREND.DENIAL_AMOUNT from (select distinct #TREND.COL_GROUP from #TREND)
AS DISTINCTTIME LEFT OUTER JOIN #TREND ON
DISTINCTTIME.COL_GROUP = #TREND.COL_GROUP
答案 0 :(得分:0)
我需要这样做的原因是Report Builder没有将日期视为实际日期,并且无法对它们进行趋势分析。我用sql函数解决了这个问题。我在这里发布这个任何处理MDX并且不得不处理奇怪日期的人。
USE [DMDS]
GO
/****** Object: UserDefinedFunction [dbo].[MonthFormat] Script Date: 12/02/2010 14:02:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Function [dbo].[MonthFormat](@date varchar(25)) Returns date as
Begin
declare @retval as varchar(50)
select @retval = case
when @date like 'Jan%' then '01/01/' + RIGHT(@Date,4)
when @date like 'Feb%' then '02/01/' + RIGHT(@Date,4)
when @date like 'March%' then '03/01/' + RIGHT(@Date,4)
when @date like 'Apr%' then '04/01/' + RIGHT(@Date,4)
when @date like 'May%' then '05/01/' + RIGHT(@Date,4)
when @date like 'Jun%' then '06/01/' + RIGHT(@Date,4)
when @date like 'Jul%' then '07/01/' + RIGHT(@Date,4)
when @date like 'Aug%' then '08/01/' + RIGHT(@Date,4)
when @date like 'Sept%' then '09/01/' + RIGHT(@Date,4)
when @date like 'Oct%' then '10/01/' + RIGHT(@Date,4)
when @date like 'Nov%' then '11/01/' + RIGHT(@Date,4)
when @date like 'Dec%' then '12/01/' + RIGHT(@Date,4)
End
return @retval
End