Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 6 of 6 total |
CASE statement in SQL |
Thu, Nov 21 2013 4:50 PM | Permanent Link |
Ben Sprei CustomEDP | I tried writing this code
update PRTempSeed set FTaxable = (GrossWage) - (FEXemp * FPerEX), STaxable = (GrossWage - (SEXemp * SPerEX) - SBaseEX, CTaxable = (GrossWage) - (SEXemp * CPerEX) - CBaseEX, SSTaxable = case when ((GrossWage + WYTD) <= 113500) then (GrossWage) when ((WYTD) > 113500) then 0 else (GrossWage + WYTD) - 113500 end and I get this error ElevateDB Error #700 An error was found in the statement at line 12 and column 1 (Missing )) What's wrong with this code Ben |
Thu, Nov 21 2013 5:24 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Hi Ben
This line:- STaxable = (GrossWage - (SEXemp * SPerEX) - SBaseEX, .... has two opening parentheses but only one closing parenthesis. Cheers Jeff -- Jeff Cook Aspect Systems Ltd www.aspect.co.nz |
Thu, Nov 21 2013 6:18 PM | Permanent Link |
Ben Sprei CustomEDP | Thanks.
"Jeff Cook" <jeffc@aspect.co.nz> wrote in message news:D45BA365-B2D7-4F66-A30A-D4480DB4FA19@news.elevatesoft.com... > Hi Ben > > This line:- > > STaxable = (GrossWage - (SEXemp * SPerEX) - SBaseEX, > > ... has two opening parentheses but only one closing parenthesis. > > Cheers > > Jeff > -- > Jeff Cook > Aspect Systems Ltd > www.aspect.co.nz > |
Fri, Nov 22 2013 12:34 PM | Permanent Link |
Ben Sprei CustomEDP | How do I write this statement
update PRTempSeed SET GrossWage = case When (< 0) then 0.00 else GrossWage end error= ElevateDB Error #700 An error was found in the statement at line 4 and column 8 (Expected expression but instead found <) SET GrossWage = (IF < 0)(GrossWage THEN 0.00 ELSE GrossWage) error = ElevateDB Error #700 An error was found in the statement at line 3 and column 5 (Expected ( but instead found <) Ben "Ben" <arrow1432@verizon.net> wrote in message news:EAA4E387-D2A1-4D37-AE3D-B96267236BD0@news.elevatesoft.com... > Thanks. > > > "Jeff Cook" <jeffc@aspect.co.nz> wrote in message > news:D45BA365-B2D7-4F66-A30A-D4480DB4FA19@news.elevatesoft.com... >> Hi Ben >> >> This line:- >> >> STaxable = (GrossWage - (SEXemp * SPerEX) - SBaseEX, >> >> ... has two opening parentheses but only one closing parenthesis. >> >> Cheers >> >> Jeff >> -- >> Jeff Cook >> Aspect Systems Ltd >> www.aspect.co.nz >> > > |
Fri, Nov 22 2013 1:36 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ben
>How do I write this statement > >update PRTempSeed >SET GrossWage case > When (< 0) then 0.00 >else GrossWage >end SQL case statements don't work like the Delphi ones. You need to fully specify the condition so update PRTempSeed SET GrossWage case When (GrossWage < 0) then 0.00 else GrossWage end but you could still have problems if GrossWage is null UPDATE PRTempSeed SET GrossWage = IF(GrossWage IS NOT NULL,IF(GrossWage < 0, 0.0, GrossWage),0)) totally untested though Roy Lambert [Team Elevate] |
Sun, Nov 24 2013 7:39 PM | Permanent Link |
Ben Sprei CustomEDP | Thanks for your reply. Ity was very helpful.
I just did some more testing and this statement would be more proper SET GrossWage = case When (GrossWage < 0) then 0.00 when (GrossWage Is Null) then 0.00 else GrossWage end BTW if I was going to convert a null to a 0 I also can use set GrossWage = coalesce(GrossWaage,0) Thanks again ben "Roy Lambert" <roy@lybster.me.uk> wrote in message news:8D162BA0-BAED-4A0F-ABD9-B2E9AB096033@news.elevatesoft.com... > Ben > >>How do I write this statement >> >>update PRTempSeed >>SET GrossWage case >> When (< 0) then 0.00 >>else GrossWage >>end > > SQL case statements don't work like the Delphi ones. You need to fully > specify the condition so > > update PRTempSeed > SET GrossWage case > When (GrossWage < 0) then 0.00 > else GrossWage > end > > but you could still have problems if GrossWage is null > > UPDATE PRTempSeed > SET GrossWage = IF(GrossWage IS NOT NULL,IF(GrossWage < 0, 0.0, > GrossWage),0)) > > totally untested though > > Roy Lambert [Team Elevate] |
This web page was last updated on Sunday, May 5, 2024 at 10:18 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |