有一张表有多个字段,其中一个字段的记录值为1的时候,需要查询出来显示为“√”。语句怎么写呢?

解决方案 »

  1.   

    select *,
    case when col = 1 then '√' else '' end as othercol
    from ta 
      

  2.   

    SELECT CASE WHEN COL1 =1 THEN '√' ELSE '' END
    FROM TB
      

  3.   


    select *, 
    case when col = 1 then '√' else '' end as othercol 
    from ta 
      

  4.   


    select *,列=case when 字段=1 then '√' end from 表
      

  5.   

    select *,字段=case 字段 when 1 then '√' else 字段 end from 表
      

  6.   

    select *, 
    case when col = 1 then N'√' else '' end as othercol 
    from ta最好加个N''
      

  7.   

    select *,字段=case 字段 when 1 then '√' else 字段 end from 表
      

  8.   

    select *, 
    case when col = 1 then '√' else '' end as othercol 
    from ta 太简单了!呵呵!只要是字符都能显示!如果要将字符加上数值型数据的话,需要用CASET,CONVERT将数值型数据转换为字符型!
      

  9.   

    感谢!在access上报错浪费了很多时间,在sql2000上没问题。