Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cardullo4321
Starting Member
40 Posts |
Posted - 2011-09-12 : 18:35:07
|
| Down below is my following query. Every I remove the Account Case Statement, I am able to execute my query. However, when I add it back, all the real columns come back as invalid columns. Does anyone know why this happens and how I can get around it?DECLARE @Payfile dec(18,2), @BaseAccrueDays dec(18,4), @Accrual_Month# dec(18,2), @PayoutRate dec(18,4), @EntityLookup varchar(20) SET @Payfile = (select top 1 [BonusLookupData].[NumberPayFile] From [BonusLookupData] Where '1' = [BonusLookupData].[Key])SELECT ,[CostCenterDesc] ,[Entity] ,Account = Case When Dept <> '450' Then '41140' Else Dept '42140' End ,[Dept] ,[SubDept] ,[Eligible Earnings YTD Calc] = round(((([Eligible_Earnings] / @Payfile) * (.0712328767123288)) FROM [SSIS_Database].[dbo].[EligibleEarningsYTD]Gregory Cardullo |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-09-12 : 18:44:53
|
I think this is a simple fixDECLARE @Payfile dec(18,2), @BaseAccrueDays dec(18,4), @Accrual_Month# dec(18,2), @PayoutRate dec(18,4), @EntityLookup varchar(20)SET @Payfile = (select top 1 [BonusLookupData].[NumberPayFile]From [BonusLookupData]Where '1' = [BonusLookupData].[Key])SELECT ,[CostCenterDesc],[Entity],Account =CaseWhen Dept <> '450' Then '41140'Else Dept '42140'End,[Dept],[SubDept],[Eligible Earnings YTD Calc] = round(((([Eligible_Earnings] / @Payfile) * (.0712328767123288))JimEveryday I learn something that somebody else already knew |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-13 : 00:29:18
|
probably you meant this?...CaseWhen Dept <> '450' Then '41140'Else Dept + '42140'End... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|