Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Nested Case Statement 1

Status
Not open for further replies.

bustercoder

Programmer
Mar 13, 2007
96
Hello, I'm trying to Use an initial CASE statement, then if that condition is satisfied, go into the next CASE statement:

[DISC WARNING] = CASE ACTNUMBR_1 WHEN '4211' THEN (SOP10102.CRDTAMNT / 2)
CASE (SOP10102.CRDTAMNT / 2) <> 50.0 THEN (SOP10102.CRDTAMNT / 2) ELSE null END END

Can someone off a better approach, or maybe show me what I'm doing wrong for this approach?

Thanks,
Buster
 
I see this as if ACTNUMBR_1 = 4211 AND SOP10102.CRDTAMNT / 2 <> 50 then [DISC WARNING] = SOP10102.CRDTAMNT / 2 else [DISC WARNING] = null

I think you are wanting this like so:
Code:
[DISC WARNING] = 
CASE WHEN ACTNUMBR_1 = '4211' 
AND (SOP10102.CRDTAMNT / 2) <> 50.0 THEN                 
  (SOP10102.CRDTAMNT / 2) 
ELSE null 
END

[monkey][snake] <.
 
I think your looking for something along these lines?

Code:
[DISC WARNING] = CASE ACTNUMBR_1 WHEN '4211' THEN 
	CASE WHEN (SOP10102.CRDTAMNT / 2) <> 50.0 THEN (SOP10102.CRDTAMNT / 2) ELSE null END END

I think you need another else in there then (after the first end).

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
and how about simplifying

(SOP10102.CRDTAMNT / 2) <> 50.0

to

SOP10102.CRDTAMNT <> 100.0

[COLOR=#aa88aa black]Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.[/color]
 
Thanks everyone for your help. Very much appreciated.
Buster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top