数据库中有的字段用1和0来表示是和否,如何用sql语句把它们用是和否来显示?

解决方案 »

  1.   

    select case when sign(field1) = 1 then '是' else '否' end from Table1
      

  2.   

    select case when 字段名=1 then '是' else '否' end from 表名字
      

  3.   

    CASE 字段 when '1' THEN '是' ELSE '否' END
      

  4.   

    select case 字段名 when 0 then '否' else '是' end from tbl
      

  5.   

    select case when 字段名=1 then '是' else '否' end from 表名字
      

  6.   

    if object_id('pubs..test') is not null
       drop table test
    go
    create table test
    (
    id varchar(10),
    value int
    )
    insert into test(id,value) values('1' , 1)
    insert into test(id,value) values('2' , 0)select * from test
    select id , case when value=1 then '是' else '否' end as value from testdrop table test--结果
    id         value       
    ---------- ----------- 
    1          1
    2          0(所影响的行数为 2 行)id         value 
    ---------- ----- 
    1          是
    2          否(所影响的行数为 2 行)