I have a CTE
that has data like this. It follows two formats pretty much where counts
and process_ids
will have these two types of data.
client_id day counts process_ids
--------------------------------------------------------------------------------------------
abc1 Feb-01-2021 3 C1,C2 | C3,C4,C5 | C6,C7
abc2 Feb-05-2021 2, 3 C10,C11,C12 | C13,C14 # C15,C16 | C17,C18
Now I want to get this below output from the above CTE
after splitting it out on counts
and process_ids
-
client_id day counts process_ids
--------------------------------------------------------
abc1 Feb-01-2021 3 C1
abc1 Feb-01-2021 3 C2
abc1 Feb-01-2021 3 C3
abc1 Feb-01-2021 3 C4
abc1 Feb-01-2021 3 C5
abc1 Feb-01-2021 3 C6
abc1 Feb-01-2021 3 C7
abc2 Feb-05-2021 2 C10
abc2 Feb-05-2021 2 C11
abc2 Feb-05-2021 2 C12
abc2 Feb-05-2021 2 C13
abc2 Feb-05-2021 2 C14
abc2 Feb-05-2021 3 C15
abc2 Feb-05-2021 3 C16
abc2 Feb-05-2021 3 C17
abc2 Feb-05-2021 3 C18
Basically, the idea is to split counts
and process_ids
basis on the below two use cases if they follow any of those formats.
UseCase 1
If counts
column only has single-digit and process_ids
column has |
delimiter.
UseCase 2
If counts
column only has two-digit separated by a ,
delimiter and process_ids
column has #
delimiter along with pipe
.
I am working with Amazon Redshift
here and I am confused about how can I split them out as needed.
Is this possible to do by any chance?