Search 800 + Posts

Dec 23, 2010

Christmas Tree Query

Found interesting Query to print Christmas Tree - 
-------------------
with Mx as (select 60 as MaxWidth from dual)
select decode 
        ( sign(floor(MaxWidth /2)-rownum) 
        , 1 
        , lpad( ' ', floor(MaxWidth /2)-(rownum-1)) || rpad( '*', 2*(rownum-1)+1, ' *') 
        , lpad( '* * *', floor(MaxWidth/2)+3)
        ) 
  from all_tables ,Mx 
where rownum < floor(MaxWidth /2) + 6;
-------------------

Happy Holidays and Merry Christmas

1 comment: