All pastes #1657615 Raw Edit

marcin

public sql v1 · immutable
#1657615 ·published 2009-11-04 23:48 UTC
rendered paste body
with recursive x( s, ind ) as( select sud, position( ' ' in sud )  from  (select '53  7    6  195    98    6 8   6   34  8 3  17   2   6 6    28    419  5    8  79'::text as sud) xx  union all  select substr( s, 1, ind - 1 ) || z || substr( s, ind + 1 )       , position(' ' in repeat('x',ind) || substr( s, ind + 1 ) )  from x     ,  (select gs::text as z from generate_series(1,9) gs)z  where ind > 0  and not exists ( select null                   from generate_series(1,9) lp                   where z.z = substr( s, ( (ind - 1 ) / 9 ) * 9 + lp, 1 )                   or    z.z = substr( s, mod( ind - 1, 9 ) - 8 + lp * 9, 1 )                   or    z.z = substr( s, mod( ( ( ind - 1 ) / 3 ), 3 ) * 3                                      + ( ( ind - 1 ) / 27 ) * 27 + lp                                      + ( ( lp - 1 ) / 3 ) * 6                                   , 1 )                 ))select sfrom xwhere ind = 0;