|
FData
Starting Member
24 Posts |
Posted - 2012-09-03 : 06:44:01
|
| Hi guys Can someone please explain to me, why i am receiving the following error message below (64685 row(s) affected)(85273 row(s) affected)(5644507 row(s) affected)(71378 row(s) affected)(71378 row(s) affected)Msg 207, Level 16, State 1, Line 91Invalid column name 'hst_merchnum'.Msg 207, Level 16, State 1, Line 91Invalid column name 'Rolling12_MSC'.Msg 207, Level 16, State 1, Line 91Invalid column name 'Rolling12_PCI'.Msg 207, Level 16, State 1, Line 91Invalid column name 'RefundTransactionCharge_2012'.Msg 207, Level 16, State 1, Line 91Invalid column name 'Other_repeatable2012'.Msg 207, Level 16, State 1, Line 91Invalid column name 'Other_Non_repeatable2012'.this is my query -------------------------------- Sales ------------------------------ Declare @Rolling12 varchar(10)set @Rolling12 = (select dateadd(MM,-12,max(hst_date_processed))from FDMS.dbo.Fact_Financial_History) SELECT FDMSAccountNo,sum([Net_Sales]) as [Net_Sales_Rolling12],SUM ([Net_Intg]) as [Net_Intg_Rolling12],SUM ([Scheme_Fees]) as [Scheme_Fees_Rolling12],SUM ([Funding_Amt]) as [Funding_Amt_Rolling12]Into #FinFROM [FDMS].[dbo].[Fact_Financial_History]f full outer join Dim_Outlet oon f.hst_merchnum = o.FDMSAccountNo_First9Where hst_date_processed > @Rolling12group by o.FDMSAccountNo--select* from #Fin--drop table #Fin --------------------------------ProcessingCost ----------------------- Declare @Rolling13 varchar(10)set @Rolling13 = (select dateadd(MM,-12,max(Period))from [FDMS].[dbo].[Fact_ProcessingCost])SELECT FDMSAccountNo,sum([Value]) as [ProcessingCost_Rolling12]Into #ProcessingFROM [FDMS].[dbo].[Fact_ProcessingCost]pWhere Period > @Rolling13group by FDMSAccountNo ------------------------------------MSC ---------------------------- Declare @Rolling14 varchar(10)set @Rolling14 = (select dateadd(MM,-12,max(Month_end_date)) FROM FDMS.dbo.Fact_Fee_History ) SELECT FDMSAccountNo,[Month_end_date] as hst_date_processed,Case when Fee_Code IN ('42B','42C','42D','42E') Then 'PCI'When Fee_Code = '00Y' Then 'Refund Transaction Charge'When salesMI_Group1 IN ('other', 'N/A') and d.repeat_msc = 'Y' then 'Other repeatable'When salesMI_Group1 IN ('other', 'N/A') and d.repeat_msc = 'N' then 'Other Non repeatable'Else salesMI_Group1 end as description,d.repeat_msc,Sum([Retail_amount]) As AmountInto #MscCountFROM FDMS.dbo.Fact_Fee_History fINNER JOIN FDMS.dbo.Dim_Fee_Codes D ON f.Fee_Sequence_Number = D.Fee_Codewhere Month_end_date> @Rolling14Group by FDMSAccountNo, Month_end_date, d.Fee_Code, d.SalesMI_Group1, d.Repeat_MSC--select * from #MscCount--drop table #MscCount,SELECT [FDMSAccountNo],--hst_date_processed, SUM ( case when description ='MSC' then ([Amount])else 0 end ) as [Rolling12_MSC], SUM ( case when description ='PCI' then ([Amount])else 0 end ) as [Rolling12_PCI], SUM ( case when description ='Refund Transaction Charge' then ([Amount])else 0 end ) as [RefundTransactionCharge_2012], SUM ( case when description ='Other repeatable' then ([Amount])else 0 end ) as [Other_repeatable2012], SUM ( case when description ='Other Non repeatable' then ([Amount])else 0 end ) as [Other_Non_repeatable2012]Into #MscFROM #MscCountgroup by [FDMSAccountNo]--hst_date_processedselect FDMSAccountNo,SUM ([Rolling12_MSC]) as [Rolling 12 MSC],sum ([Rolling12_PCI]) as [Rolling 12 PCI],sum([RefundTransactionCharge_2012]) as [Rolling 12 RTCharge],sum ([Other_repeatable2012]) as [Rolling 12 OtherRep],sum([Other_Non_repeatable2012]) as [Rolling 12 NonRep]Into #msc1from #Mscgroup by [FDMSAccountNo]--Drop table #msc1, #msc--select * from #msc------------------------------------Results Layout---------------------------------Select p.FDMSAccountNo, [Net_Sales_Rolling12] as [Rolling 12 Net Sales], [Net_Intg_Rolling12] as [Rolling 12 Net Interchange], [Scheme_Fees_Rolling12] as[Rolling 12 Scheme Fees], [Funding_Amt_Rolling12] as [Rolling 12 Funding], [Rolling12_MSC] as [Rolling 12 MSC], [Rolling12_PCI] as [Rolling 12 PCI], [RefundTransactionCharge_2012] as [Rolling 12 RTCharge], [Other_repeatable2012] as [Rolling 12 OtherRep], [Other_Non_repeatable2012] as [Rolling 12 NonRep] Into #results from #Fin f full outer join #Processing p on f.hst_merchnum = left(p.FDMSAccountNo,9) full outer join #msc1 m on p.FDMSAccountNo = m.FDMSAccountNo ------------------------------ Calculations ------------------------------Select *, [Rolling12_MSC]-[Net_Intg_Rolling12] as [Rolling 12 DI],[Rolling12_MSC]-[Net_Intg_Rolling12] -[Scheme_Fees_Rolling12] as [Rolling 12 DIA],SUM ([Rolling 12 DIA]+[Other_repeatable2012]+[Rolling 12 Funding])- SUM([ProcessingCost_Rolling12]) as [rolling 12 Repcon]----------------------------------- F Results -----------------Into #FinalResults From #results group by [FDMSAccountNo],[Rolling 12 Net Sales],[Rolling 12 Net Interchange],[Rolling 12 Scheme Fees],[Rolling 12 Funding],[Rolling 12 MSC],[Rolling 12 PCI],[Rolling 12 RTCharge],[Rolling 12 OtherRep],[Rolling 12 NonRep]select o.ParentID,F.* from #FinalResults finner join fdms.dbo.Dim_Outlet o on o.FDMSAccountNo = f.FDMSAccountNo--Drop table #Fin,#Processing, #MscCount,#Msc,#msc1,#FinalResults ,#results |
|