蟆郁骸 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