Reputation: 13
I tried to replace value from 'operation_num' if 'column_task' has the particular value. But I cannot find suitable statement. Could you help me?
FYI: column 'operation_num' does not include any NULL value.
WHERE
CASE operation_num WHEN column_task = 'EXERCISE' THEN operation_num is null
ELSE operation_num -- operation_num = operation_num
END
Thanks
Upvotes: 0
Views: 760
Reputation: 1
SELECT distinct ID,
CASE
WHEN COLUMN2 is not NULL then COLUM1||'#'|| COLUMN2
ELSE COLUMN1
END
FROM table ;
this query shows result as column1# which is wrong ,when it's null then it should show column value
Upvotes: 0
Reputation: 40491
Convert it to AND/OR
(will also have better performance) :
WHERE (column_task = 'EXERCISE' and operation IS NULL)
OR operation_num
Though I don't understand the last condition .
Upvotes: 1
Reputation: 1271091
I think you intend:
WHERE column_task <> 'EXERCISE' OR operation_num IS NULL)
Upvotes: 0
Reputation: 13
I am sorry for my wrong question. I solved finally my issue in 'SELECT' part in query:
select
(case when (to_char(operation_num) = '10' and column_task = 'EXERCISE')
then REPLACE(to_char(operation_num),'10',' ')
else to_char(operation__num)
end) as "column"
,column_task
from my_table
But thank you all for your efforts.
Upvotes: 0
Reputation: 37493
Try this
WHERE
CASE WHEN column_task = 'EXERCISE' THEN null
ELSE operation_num
END
Upvotes: 2
Reputation: 32021
I think it would be like below
WHERE
(CASE column_task WHEN 'EXERCISE' THEN null
ELSE operation_num end)= value
Upvotes: 1