_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › T-sqlGreatest豌危蠍

microsoft sql server greatest 螳 .
蠏碁 朱朱 dummy 企螻 cross join伎 max襯 豺 蠍磯(=蠍磯1) .
蠏碁磯, 蠍磯 譬 蠏谿. 蠏谿 蠍 れ 蠍磯(=蠍磯2) 螳.

一危
create table #temp(
    col1 int
,   col2 int
,   col3 int
,   col4 int
,   col5 int
)
insert #temp values(1,2,3,4,5)

蠍磯1
select 
    max(
        case
            when b.col = 1 then col1
            when b.col = 2 then col2
            when b.col = 3 then col3
            when b.col = 4 then col4
            when b.col = 5 then col5
        end
    ) max_value
from #temp a
    cross join (values (1),(2),(3),(4),(5)) b (col)

蠍磯2
select 
    max(b.col) max_value
from #temp a
    cross apply (values (a.col1),(a.col2),(a.col3),(a.col4),(a.col5)) b (col)

蠍磯1覲企 蠍磯2螳 譬 ?
  • 貊 所 譴企.
  • 焔レ 螳り 覺 覓企逢.
  • 螳煙? 覈襯願.
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

覲伎覲企る 瑚鴬 襴れ朱 レ螻 矩. 覲伎 覓殊 譯殊伎 覦覃 瑚鴬 . (B. 朱)