请问:在SQL中,如果需要对某两个值进行判断分析,应该用什么函数?此函数的性质就诸如Excel中的IF函数,例如:
A=100,B=300
使用IF函数就是:if(A<>B,"错误","正常"),那么此语句使用SQL应该怎样书写?应该使用什么函数呢?

解决方案 »

  1.   

    Select case when A>B then "错误" else "正常" end
      

  2.   

    case when A <> B then '错误'
                    else '正常'
                    end
      

  3.   

    select case A when B then '正常' else '错误' end from [Table]
      

  4.   

    CREATE FUNCTION dbo.F_Test( @A int,  @B int)
    RETURNS  varchar(100)  AS  
    BEGINreturn (Select case when @A<>@B then '错误' else '正常' end)ENDSelect  dbo.F_Test(100,300)------
    错误
      

  5.   

    select case then A<>B  then 'false' else 'true' end
      

  6.   

    declare @A int
    declare @B intset @A= 100
    set @B = 200 
    select case @A when   @B  then  '正常'  else '错误'  end
      

  7.   

    Select case when A<>B then "错误" else "正常" end
      

  8.   

    估计是想问iif函数吧,上面说的差不多了