数据库sqlserver
我的数据库表中有一个int的字段,里面的值只可能是1或者0,我要用一条sql语句写出来,如果是1就用“是”显示,如果是0就用“否”显示,如果做!
比如:表结构如下
cerate table table_test
(
test_int int
)
我的数据库表中有一个int的字段,里面的值只可能是1或者0,我要用一条sql语句写出来,如果是1就用“是”显示,如果是0就用“否”显示,如果做!
比如:表结构如下
cerate table table_test
(
test_int int
)
我的数据库表中有一个int的字段,里面的值只可能是1或者0,我要用一条sql语句写出来,如果是1就用“是”显示,如果是0就用“否”显示,如果做!
比如:表结构如下
cerate table table_test
(
test_int int
) select case 字段 when 1 then '是' else '否' end from tb
select test_int=case when 1 then'是'else '否'
case test_int
WHEN 1 THEN '是'
WHEN 0 THEN '否'
from table_test order by test_int
查询的结果显示字段---“无列名”,如果我要显示列名(别名),要如何写?谢谢!
select case 字段 when 1 then '是' when 0 then '否' else '其他' end as 字段名 from tb
select case 字段 when 1 then '是' when 0 then '否' else '其他' end as 别名 from tb