tsql - Add Null rows to table in stored procedure -
i have table:
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
i need able add september (or col_group field) table nulls in claim_count , denial_amount. row_group , col_group dynamically generated can't update fields, has done within stored procedure. mentioned outer left join might create these nulls me, not sure how. suggestions helpful.
it suggested use sql statement colleague @ work, doesn't seem work:
select #trend.row_group, distincttime.col_group, #trend.claim_count, #trend.denial_amount (select distinct #trend.col_group #trend) distincttime left outer join #trend on distincttime.col_group = #trend.col_group
the reason needed report builder wasn't viewing dates dates , couldn't trend them. solved using sql function. i'm posting here dealing mdx , having deal weird dates.
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 begin declare @retval varchar(50) select @retval = case when @date 'jan%' '01/01/' + right(@date,4) when @date 'feb%' '02/01/' + right(@date,4) when @date 'march%' '03/01/' + right(@date,4) when @date 'apr%' '04/01/' + right(@date,4) when @date 'may%' '05/01/' + right(@date,4) when @date 'jun%' '06/01/' + right(@date,4) when @date 'jul%' '07/01/' + right(@date,4) when @date 'aug%' '08/01/' + right(@date,4) when @date 'sept%' '09/01/' + right(@date,4) when @date 'oct%' '10/01/' + right(@date,4) when @date 'nov%' '11/01/' + right(@date,4) when @date 'dec%' '12/01/' + right(@date,4) end return @retval end
Comments
Post a Comment