Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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 6, 2013 11:41 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, December 5, 2016 1:55 PM
Points: 129, Visits: 733
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 6, 2013 1:32 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:56 AM
Points: 7,969, Visits: 19,092
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

If your posting includes some T-SQL code, please surround the code with IFCode formatting tags. It helps readability a lot.
Post #1416713
Posted Wednesday, February 6, 2013 1:41 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, December 5, 2016 1:55 PM
Points: 129, Visits: 733
I figured this one out by using the && operator. Thanks
Post #1416718
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse