on ‎2020 Oct 14 10:37 AM
I have a case statement in SQL
Case when Fieldname like '%[0-9]%' then NULL else Fieldname end as Field
This works fine when the SQL is run by itself, but when embedded on SQL Transform and utilized on a Dataflow, it skips the whole statement and renders Fieldname for Field.
Things I tried
1. I tried to use Match_regex in the Query transform. But since the field does not have a pattern and a number could be any where, that did not work.
2. Tried ifthenelse on Query transform, no luck.
I have looked up all the Q&A and forums could not find a solution, please suggest. Thank you.
Request clarification before answering.
Hi there,
have you tried using match_simple?
match_simple(FieldName,'$') = 0You could use it in a query transform as in:
Ifthenelse(match_simple(FieldName,'$') = 0, NULL, FieldName)Regards,
Julian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there,
I have done some quick tests for you - the above was just out of my head and I did not test it either.
I forgot the single quotes in above Query:
Ifthenelse(match_simple(FieldName,'$') = 0, NULL, FieldName)Also, if you want to turn it around like wdaehn suggested, you can use:
Ifthenelse(match_simple(FieldName,'$') = 1, FieldName, NULL)The dollar sign represents any alphabetic character, including non-English letters, zero or more times.
Also you can use what wdaehn suggested below, but you would need to put it like this:
ifthenelse(match_simple(FieldName,'*[0..9]*')= 0, FieldName, null)
regards,
Julian
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.