34,591
社区成员
发帖
与我相关
我的任务
分享
--> my name is sinpoal
-
create table ta (ID char ,taname char(4),TypeID int )
insert into ta
select '1','张三','1' union all
select '2','李四','1'
select * from ta
--drop table ta
select
max (case when ta.ID='1' then ID end) ID,
max (case when ta.taname ='张三' then taname end) +','+
max (case when ta.taname ='李四' then taname end)name,
max (case when ta.TypeID='1' then TypeID+1 end) TypeID
from ta
-- my name is sinpoal
--测试表
create table ta (ID char ,taname char(4),TypeID int )
insert into ta
select '1','张三','1' union all
select '2','李四','1'
select * from ta
--drop table ta
select
max (case when ta.ID='1' then ID end) ID,
max (case when ta.taname ='张三' then taname end) name,
max (case when ta.taname ='李四' then taname end)name,
max (case when ta.TypeID='1' then TypeID+1 end) TypeID
from ta
/*
ID name name TypeID
1 张三 李四 2
(1)行受影响*/