Skip to content

Instantly share code, notes, and snippets.

@dz0
Created March 18, 2020 14:11
Show Gist options
  • Save dz0/3473d72b7f191fb98e5c92f30816b1e1 to your computer and use it in GitHub Desktop.
Save dz0/3473d72b7f191fb98e5c92f30816b1e1 to your computer and use it in GitHub Desktop.
; nice formatting of https://www.vertica.com/blog/vertica-quick-tip-splitting-string-rows/
=> SELECT * FROM test;
id | c2
----+-------
1 | A|B|C
2 | D|E|F
(2 rows)
;;;;;
=> SELECT id, words FROM (
SELECT id, StringTokenizerDelim(c2, ‘|’)
OVER (PARTITION BY id ORDER BY id)
FROM test)
ORDER BY 1, 2;
id | words
—-+——-
1 | A
1 | B
1 | C
2 | D
2 | E
2 | F
(6 rows)
@ethanbergstrom
Copy link

Thanks for this!

@ahenry111
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment