22 December 2009

Best Wishes

Let SQL do the talking:

select decode
(sign (floor (maxwidth/2) - rownum)
,1, lpad (' ', floor (maxwidth/2) - (rownum -1))
||rpad ('*', 2 * (rownum -1), ' *')
,lpad ('* * *', floor (maxwidth/2) + 3)) "Merry Christmas"
from all_objects
, (select 40 as maxwidth from dual)
where rownum < floor (maxwidth/2) + 5


... and in case your wondering what the result would be, I added a screenshot.




Best wishes and a Happy New Year!

2 comments:

  1. Alex,
    For next year:
    select decode( sign (21 - rownum)
    , 1, lpad (' ', 24 - mod(rownum-1,4) - (rownum - 1))
    ||rpad ('*', 2 * (rownum - 1) - (6-2*mod(rownum-1,4)), ' *')
    , lpad ('* * *', 23)) "Merry Christmas"
    from all_objects
    where rownum < 26

    (created by a collegue of me)

    Regards Erik

    ReplyDelete