Skip to content

Instantly share code, notes, and snippets.

@alexlopes
Created March 14, 2019 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlopes/597b44dbf345f22dd8407d9215e3dc79 to your computer and use it in GitHub Desktop.
Save alexlopes/597b44dbf345f22dd8407d9215e3dc79 to your computer and use it in GitHub Desktop.
SQL Tricks
select a.*, b.id from 

(
       select * from (
                       select regexp_substr('TC,HBO,FUT','[^,]+',1,level) element, level as lvl
                       from dual             connect by level <= length(regexp_replace('TC,HBO,FUT','[^,]+')) + 1 
                       )   
       PIVOT ( MAX(element) FOR lvl IN (1,2,3)) mypivot 
) a, something.table b   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment