select field=case when S_L is null then 'S_X' else 'S_L' end, fieldvalue=case when S_L is null then S_X else S_L end from test
同意楼上的,一下是测试语句create table temp1 (id int identity(1,1), s_x int, s_l int) insert into temp1(S_X) values(2)select * from temp1select field=case when S_L is null then 'S_X' else 'S_L' end, fieldvalue=case when S_L is null then S_X else S_L end from temp1
id很多 获取id后 首先要去s_l字段 如果该字段的值为null 就去s_x 谢谢楼上的!
fieldvalue=case when S_L is null then S_X else S_L end
from test
(id int identity(1,1),
s_x int,
s_l int)
insert into temp1(S_X)
values(2)select * from temp1select field=case when S_L is null then 'S_X' else 'S_L' end,
fieldvalue=case when S_L is null then S_X else S_L end
from temp1