trimming and removing particular string from sql
Wed Apr 06 2022 04:53:35 GMT+0000 (Coordinated Universal Time)
Saved by
@Bambibo9799
-----
SELECT order_id, runner_id,
CASE
WHEN pickup_time LIKE 'null' THEN ' '
ELSE pickup_time
END AS pickup_time,
CASE
WHEN distance LIKE 'null' THEN ' '
WHEN distance LIKE '%km' THEN TRIM('km' from distance)--- remove km from column
ELSE distance END AS distance,
CASE
WHEN duration LIKE 'null' THEN ' '
WHEN duration LIKE '%mins' THEN TRIM('mins' from duration)-- remove mins
WHEN duration LIKE '%minute' THEN TRIM('minute' from duration)---remove minute
WHEN duration LIKE '%minutes' THEN TRIM('minutes' from duration)--remove minutes from duration
ELSE duration END AS duration,
CASE
WHEN cancellation IS NULL or cancellation LIKE 'null' THEN ''
ELSE cancellation END AS cancellation
--INTO temp_runner_orders
FROM runner_orders;
content_copyCOPY
Comments