select a,b=case when a=0 then b else null end from tb
select B from table where A=(select A from table where A=0)
select a,case when a=1 then null else b end b from tb
select a,b=case when a=0 then b else null end from tba b ----------- ----------------------- 0 NULL 1 NULL 0 NULL 0 16:00(4 行受影响)
drop table #temp go create table #temp ( A int, B varchar(100) ) goinsert into #temp values(0, NULL) insert into #temp values(1, '15:00') insert into #temp values(0, NULL) insert into #temp values(0, '16:00')select * from #temp goselect a, (case when a = 1 then NULL else B end) as B from #temp
首先谢谢诸位的帮助,以上命令我在SQL2000中运行,出现'='附件有错误,但把b=去掉后就运行成功了。 select a,case when a=0 then b else null end from tb
from tb
select a,case when a=1 then null else b end b
from tb
from tba b
----------- -----------------------
0 NULL
1 NULL
0 NULL
0 16:00(4 行受影响)
drop table #temp
go
create table #temp
(
A int,
B varchar(100)
)
goinsert into #temp values(0, NULL)
insert into #temp values(1, '15:00')
insert into #temp values(0, NULL)
insert into #temp values(0, '16:00')select * from #temp
goselect a, (case when a = 1 then NULL else B end) as B
from #temp
首先谢谢诸位的帮助,以上命令我在SQL2000中运行,出现'='附件有错误,但把b=去掉后就运行成功了。
select a,case when a=0 then b else null end
from tb