3 #

覓語 sqler.pe.kr 覦蟆 覓語([http](http://sqler.pe.kr/web_board/view_list.asp?id=1218&read=149&pagec=1&gotopage=1&block=0&part=myboard7&tip=ok)). 襷襦 螳覲企 覓語螳 螳碁 觜訣 覦朱 碁 覓語. 覩語蟶 螳 螳襷 企瓦給. (襴襷 危危る 碁企 蟇企讌 讌.)

 蟆郁骸

num         a    b    c    d    e
----------- ---- ---- ---- ---- ----
5                              
4                              
3                             
2                             
1                            
0                           
NULL        1    3    5    0    2
--貎朱Μ 蟆郁骸 ろ碁 覲願 螻蠍語 佔(~~豌)襦 覲企 . 旧 覦蠑碁蟇 蠏谿朱 覃覈レ朱 覲旧伎 覲企 . 
with temp(num)
as
(
        select 6 numm
        union all
        select num - 1 from temp
        where num - 1 >= 0
),
val(a,b,c,d,e)
as
(
	select '1' a, '3' b, '5' c, '0' d, '2' e
)
select 
	case when b.num = 0 then null else b.num - 1 end num
,	case when b.num = 0 then a when b.num - 1 <= a.a then '' else '' end a
,	case when b.num = 0 then b when b.num - 1 <= a.b then '' else '' end b	
,	case when b.num = 0 then c when b.num - 1 <= a.c then '' else '' end c
,	case when b.num = 0 then d when b.num - 1 <= a.d then '' else '' end d
,	case when b.num = 0 then e when b.num - 1 <= a.e then '' else '' end e
from val a
	cross join temp b