Skip to content

Instantly share code, notes, and snippets.

@tangotiger
Created November 5, 2016 01:56
Show Gist options
  • Save tangotiger/a693648b65aa54d7bf2bb387210d6cb3 to your computer and use it in GitHub Desktop.
Save tangotiger/a693648b65aa54d7bf2bb387210d6cb3 to your computer and use it in GitHub Desktop.
WITH
rs as (
select
instr(play_string,',',1,6) as comma_position
, play_string
from mytable
where substr(play_string,1,4)='play'
)
,
rs2 as (
select
substr(play_string,1,comma_position-2) as prefix_parse
, substr(play_string,comma_position-1,1)as replace_parse
, substr(play_string,comma_position) as suffix_parse
, rs.*
from rs
)
select
play_string
, prefix_parse || 'X' || suffix_parse as new_play_string
from rs2
where replace_parse in ('D', 'E')
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment