I’m using the following where condition in a fixed sql query:
and ([NC_DATA].WORK_CENTER_BO LIKE '%[Param.4]%' OR '[Param.4]' IS NULL)
and its working fine when I enter a value for Param.4, but when I don’t use Param.4 it’s not giving the NULL paramter only data with values. How can I achieve that I get data with values and also data = NULL
Thanks for helping!
What I tried:
and ([NC_DATA].WORK_CENTER_BO LIKE '%[Param.4]%' OR '[Param.4]' IS NULL)
I get:
| Column 1 | WORK_CENTER_BO |
|---|---|
| ABC | 123 |
| DEF | 456 |
I expecting:
| Column 1 | WORK_CENTER_BO |
|---|---|
| ABC | 123 |
| DEF | 456 |
| GHI | NULL |
>Solution :
You can try using the COALESCE function as follows:
and (COALESCE([NC_DATA].WORK_CENTER_BO, '[Param.4]') LIKE '%[Param.4]%')
If your "WORK_CENTER_BO" is null, it will be replaced with [Param.4] to match the condition.