September 8, 2014 at 3:10 am
hi I want to do this
BASIS_IND == "A" ? ||BASIS_IND == "T" ? : "Comp A" "Comp T" : "Comp"
but I keep getting an error
what im trying to do is set a - coma t = to compt and anything that's not a or t just set it to comp. whats the best way to do this
September 8, 2014 at 4:54 am
Try removing the first question mark.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 8, 2014 at 7:12 am
hi
no taking out first ? doesn't work
when I used this I get an error
BASIS_IND == "A" ||BASIS_IND == "T" ?: "Comp A": "Comp T" : "Comp"
September 8, 2014 at 7:51 am
The basic syntax is as follows:
boolean_expression?expression1:expression2
Your expression
BASIS_IND == "A" ||BASIS_IND == "T" ?: "Comp A": "Comp T" : "Comp"
has an 'expression3' - which I imagine is causing the error. (In future, kindly post the error message too.)
This would probably work:
(BASIS_IND == "A" ||BASIS_IND == "T)?: "Comp A": "Comp T"
Can you state your desired logic in English? Perhaps I can help you achieve what you want.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 8, 2014 at 7:59 am
ok is there anyway I cant put the 3 rd expression in as anything that's not a or t I just want as comp
September 8, 2014 at 8:33 am
ronan.healy (9/8/2014)
ok is there anyway I cant put the 3 rd expression in as anything that's not a or t I just want as comp
There is no need for a third expression. Consider
boolean_expression?expression1:expression2
Expression1 is evaluated if boolean_expression is true.
If not, Expression2 is evaluated.
There is no way that neither of the expressions would be evaluated.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 8, 2014 at 8:37 am
Perhaps something like this?
BASIS_IND == "A" ||BASIS_IND == "T" ?: "Comp " + BASIS_IND : "Comp"
You might need to use & instead of + to concatenate the text - can't remember which works.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 9, 2014 at 2:51 am
ill probably have to use an sql script to update the columns as that doesn't get all 3 in for me
September 9, 2014 at 3:35 am
ronan.healy (9/9/2014)
ill probably have to use an sql script to update the columns as that doesn't get all 3 in for me
Please explain why not.
I thought you wanted Comp A, Comp T and Comp. My expression should do that.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 19, 2014 at 4:06 am
sorry that did work. thought I replied ti this
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply