三个数据,插入个表变量或者临时,然后用min就可以了

解决方案 »

  1.   

    存储过程里写if条件判断或者select里写case when排列组合判断
      

  2.   


    declare @a int,@b int,@c int
    select @a=6,@b=5,@c=7select case when @a<=@b and @a<=@c then @a
                when @b<=@a and @b<=@c then @b
                when @c<=@a and @c<=@b then @c end 'min_value'/*
    min_value
    -----------
    5(1 row(s) affected)
    */
      

  3.   

    可以不用存储过程,写个function,里面做if判断也行
      

  4.   

    select min(col) from (select @a as col union all select @b union all select @c) as t