Skip to content

Instantly share code, notes, and snippets.

@choplin
Created September 1, 2015 16:06
Show Gist options
  • Save choplin/fe9171ef9436bb4d651c to your computer and use it in GitHub Desktop.
Save choplin/fe9171ef9436bb4d651c to your computer and use it in GitHub Desktop.
WITH RECURSIVE r AS (
SELECT 35 / 8 q, 35 % 8 r
UNION
SELECT q/8, q%8 FROM r WHERE q > 0
)
SELECT string_agg(r::text, '' ORDER BY q)::int FROM r;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment