select (case when jongjifen>200 then 0 else 1 end) as state from tb
if object_id('[tb]') is not null drop table [tb] go create table [tb]( [state] as case when jongjifen>200 then 1 else 0 end, [jongjifen] int ) go insert tb(jongjifen) select 200 union all select 201 union all select 2 goselect * from tb /** state jongjifen ----------- ----------- 0 200 1 201 0 2(所影响的行数为 3 行) **/
go
create table [tb](
[state] as case when jongjifen>200 then 1 else 0 end,
[jongjifen] int
)
go
insert tb(jongjifen)
select 200 union all
select 201 union all
select 2
goselect * from tb
/**
state jongjifen
----------- -----------
0 200
1 201
0 2(所影响的行数为 3 行)
**/
from table1
then ..
else..
end