select t.xx,  (case  
     when t.xx = '100006' then
       'OK'
     when t.xx= '100005' then
       'NO'
     else
         'OOOO'
   end ) AS item_id  
  from aa  t

解决方案 »

  1.   

    case 字段名 when 'A' then 'F1'
                when 'B' then 'F2'
                else 'T'
                end
      

  2.   

    IF A
         SELECT 'F1'
    ELSE IF B
         SELECT 'F2'
    ELSE
      BEGIN
         INSERT INTO 表
            .
            .
      END 
      

  3.   

    IF A
         SELECT 'F1'
    ELSE IF B
         SELECT 'F2'
    ELSE
      BEGIN
         INSERT INTO 表
            .
            .
      END 
      

  4.   

    尝试错误
    大概思路是传入用户ID 级别 时间字符串 
    先判断 表内是不是有相同时间字符串 
    有 则返回F1在判断该用户在表内的记录数 超过数量
    返回F0以上两个条件通过
    插入记录---------------
    CREATE PROCEDURE notic_add@id  VarChar (50),
    @ulevel  int,
    @notic_time  VarChar (50),
    @notic_com   VarChar (50),
    @mesage  VarChar (10)='' outputAS
    declare @countid intif exists  (select  * from  表 where notic_time=@notic_time and notic_user=@id) 
    begin
    set @mesage ='f0'
    endelse begin
    insert into  表
    (notic_time,notic_com,notic_user )values (@notic_time,@notic_com ,@id)
     set @mesage ='t'
    end
    GO
      

  5.   

    CREATE PROCEDURE notic_add@id  VarChar (50),   --用户id
    @ulevel  int,        --级别
    @notic_time  VarChar (50), --时间字符串
    @notic_com   VarChar (50),
    @mesage  VarChar (10)='' output
    ASdeclare @countid intif exists (select  * from  表 where notic_time=@notic_time and notic_user=@id) 
       select @mesage ='f1'
    select @countid = select count(*) from 表 where notic_user=@idif @countid >数量
        select @mesage ='f0'
    else 
        begin
    insert into  表(notic_time,notic_com,notic_user )
    values (@notic_time,@notic_com ,@id)
        set @mesage ='t'
    end
    GO
      

  6.   

    CREATE PROCEDURE notic_add
    @id  VarChar (50),   --用户id
    @ulevel  int,        --级别
    @notic_time  VarChar (50), --时间字符串
    @notic_com   VarChar (50),
    @mesage  VarChar (10)='' output
    AS
    declare @countid intdeclare @countid intif exists (select  * from  表 where notic_time=@notic_time and notic_user=@id) 
       begin
    set @mesage ='f0'
    end
    set  @countid=(select  count(id) from 表where notic_user=@id)
    if @countid>=(@ulevel*2)
    set @mesage ='f1'
    else begin
    insert into  lsb_member_notic (notic_time,notic_com,notic_user )values (@notic_time,@notic_com ,@id)
     set @mesage ='t'
    end
    GO以上代码 
    第一条判断没起作用
    当@mesage ='f0' 不会向下执行
    当if exists (select  * from  表 where notic_time=@notic_time and notic_user=@id) 
    即 可以录入相同内容到notic_time字段
    而本意是不可以录入相同内容到该字段