What's the best way to select the minimum value from several columns?

后端 未结 19 2042
余生分开走
余生分开走 2020-11-27 02:47

Given the following table in SQL Server 2005:

ID   Col1   Col2   Col3
--   ----   ----   ----
1       3     34     76  
2      32    976     24
3       7             


        
相关标签:
19条回答
  • 2020-11-27 03:52
    select *,
    case when column1 < columnl2 And column1 < column3 then column1
    when columnl2 < column1 And columnl2 < column3 then columnl2
    else column3
    end As minValue
    from   tbl_example
    
    0 讨论(0)
提交回复
热议问题