Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Help with Derived Column Expression Expand / Collapse
Author
Message
Posted Wednesday, February 06, 2013 11:41 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 5:14 AM
Points: 85, Visits: 403
This is working great but I need to add another piece and my brain just cant get it. So, Thanks

([CONV CODECURNRC] == "CAD" ? [CONV AMTNETTOT] - [CONV Payments] : ([CONV AMTNETTOT] - [CONV Payments]) * [CONV EXCHRATEHC]) 


What I need to do is evaluate the above statement and if it evaluates to < = 0 THEN 0, Otherwise evaluate just the above statement.
Post #1416667
Posted Wednesday, February 06, 2013 1:32 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 5:12 AM
Points: 4,226, Visits: 9,458
You could add another level of nesting:

Expression < 0 ? 0 : Expression

where expression is the entire statement you currently have.

Or - slightly unorthodox - add another derived column transformation after this one and you can build another expression using the column you have just created. Avoids the nasty nesting.


____________________________________________________________________________________________

Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:

http://www.sqlservercentral.com/articles/Best+Practices/61537/

If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
Post #1416713
Posted Wednesday, February 06, 2013 1:41 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 5:14 AM
Points: 85, Visits: 403
I figured this one out by using the && operator. Thanks
Post #1416718
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse