|
发表于 2020-1-11 04:09:02
|
显示全部楼层
create table tablename(
a char(10),
b char(10),
c int )
insert into tablename
select 'aa','bb',0
union all
select 'cc','dd',1
select tablename.*, value=case when c=0 then a else b end from tablename
结果:
a b c value
aa bb 0 aa
cc dd 1 dd |
|