Sql语句中 case when .. 的两种写法
在 SQL查询语句中,
case 语句的两种写法(SqlServer 2005 下测试通过):
1. select (case 字段1
when a then 0
when b then 1
else 2
end
) as tmpField
from [table]
2. select (case
when 字段1 = a then 0
when 字段1 = b then 1
else 2
end
) as tmpField
from [table]
when a then 0
when b then 1
else 2
end
) as tmpField
from [table]
2. select (case
when 字段1 = a then 0
when 字段1 = b then 1
else 2
end
) as tmpField
from [table]