sqlserver查询数据问题
发布网友
发布时间:2022-04-08 07:01
我来回答
共2个回答
热心网友
时间:2022-04-08 08:31
select max(name1),max(name2),max(name3),max(name4) from
(select name as name1,''as name2,''as name3,''as name4 from table where name='AAA'
union
select ''as name1,name as name2,''as name3,''as name4 from table where name='BBB'
union
select ''as name1,''as name2,name as name3,''as name4 from table where name='CCC'
unoiin
select ''as name1,''as name2,''as name3,name as name4 from table where name='DDD')
热心网友
时间:2022-04-08 09:49
select name1,name2,name3,newname3 name4 from(
select name1,name2,left(newname2,charindex(',',newname2)-1) as name3,SUBSTRING(newname2,charindex(',',newname2)+1,LEN(newname2)) as newname3 from
(
select name1,left(newname1,charindex(',',newname1)-1) as name2,SUBSTRING(newname1,charindex(',',newname1)+1,LEN(newname1)) as newname2 from
(
select LEFT(name,charindex(',',name)-1) as name1,SUBSTRING(name,charindex(',',name)+1,LEN(name)) as newname1 from b
) tb1
) tb2
) tb3