Skip to content

Instantly share code, notes, and snippets.

@ticklemynausea
Created October 2, 2013 11:59
Show Gist options
  • Select an option

  • Save ticklemynausea/6792610 to your computer and use it in GitHub Desktop.

Select an option

Save ticklemynausea/6792610 to your computer and use it in GitHub Desktop.
Arvorezinha 2.0 em Oracle SQL
select * from (
select 'a'||lpad(level, 5,'0') as linha,
rpad(' ', &altura-level, ' ') || rpad('*', 2*level-1, '*') as arvorezinha
from dual
connect by level <= &altura
union
select 't'||lpad(level, 5,'0') as linha,
rpad(' ', ((2*&altura-1)/4)+1, ' ')||rpad('#', (2*&altura-1)/2, '#')
from dual
where mod(&altura, 2) = 0
connect by level <= (&altura/2)
union
select 't'||lpad(level, 5,'0') as linha,
rpad(' ', ((2*&altura-1)/4), ' ')||rpad('#', (2*&altura-1)/2+1, '#')
from dual
where mod(&altura, 2) > 0
connect by level <= (&altura/2)
) order by linha asc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment