Evan845
I'm trying to do some string manipulation with a particular column that has cells with records like '2,6' or '3,4'. I'm trying to CAST this to an INT so I can perform aggregations (sum, avg, etc). 



```
DROP TABLE IF EXISTS customer_orders;
CREATE TABLE customer_orders (
  "order_id" INTEGER,
  "customer_id" INTEGER,
  "pizza_id" INTEGER,
  "exclusions" VARCHAR(4),
  "extras" VARCHAR(4),
  "order_time" TIMESTAMP
);

INSERT INTO customer_orders
  ("order_id", "customer_id", "pizza_id", "exclusions", "extras", "order_time")
VALUES
  ('1', '101', '1', '', '', '2020-01-01 18:05:02'),
  ('2', '101', '1', '', '', '2020-01-01 19:00:52'),
  ('3', '102', '1', '', '', '2020-01-02 23:51:23'),
  ('3', '102', '2', '', NULL, '2020-01-02 23:51:23'),
  ('4', '103', '1', '4', '', '2020-01-04 13:23:46'),
  ('4', '103', '1', '4', '', '2020-01-04 13:23:46'),
  ('4', '103', '2', '4', '', '2020-01-04 13:23:46'),
  ('5', '104', '1', 'null', '1', '2020-01-08 21:00:29'),
  ('6', '101', '2', 'null', 'null', '2020-01-08 21:03:13'),
  ('7', '105', '2', 'null', '1', '2020-01-08 21:20:29'),
  ('8', '102', '1', 'null', 'null', '2020-01-09 23:54:33'),
  ('9', '103', '1', '4', '1, 5', '2020-01-10 11:22:59'),
  ('10', '104', '1', 'null', 'null', '2020-01-11 18:34:49'),
  ('10', '104', '1', '2, 6', '1, 4', '2020-01-11 18:34:49');
```

As you can see, the exclusions and extras columns have the literal string 'null'. I was hoping this query would resolve it:

```
update customer_orders
set extras = case when extras is null then replace(extras, null , '')
  when extras like 'null' then replace(extras, 'null','')
else extras
end;
```

However, the results aren't what I was hoping for:

![image.png](/image?hash=ca8eac279ced01a075067cd4c7624175073cf6fb92190a8d28a74dd4cc477978)

The 'NULL' is still there for some reason. Any ideas why?
Top Answer
Truilus
Well, that's a NULL _value_ not the the string `'null'`. You need to just set the value to an empty string. Calling `replace()` on a NULL value, won't change anything. The replace() on the string `null` doesn't really make sense either. You can combine both conditions: 


    set extras = case 
                   when extras is null or extras = 'null' then ''
                   else extras
                 end

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.