34,838
社区成员




;with tb(Code,[Name],no) as (
select 'A019',N'建设中',1 union all
select 'A018',N'北京',2 union all
select 'A019',N'完成',3 union all
select 'A018',N'上海',4
)
select * from tb
/*
Code Name no
A019 建设中 1
A018 北京 2
A019 完成 3
A018 上海 4
*/
;with tb(Code,[Name],no) as (
select 'A019',N'建设中',1 union all
select 'A018',N'北京',1 union all
select 'A019',N'完成',2 union all
select 'A018',N'上海',2
)
select no,max(case when code='A018' then [Name] else '' end) as city,max(case when code='A019' then [name] else '' end) as status from tb
group by no
/*no city status
1 北京 建设中
2 上海 完成
*/
select case when 编号='A018' then 名称 end as 行政区域名称,
case when 编号='A019' then 名称 end as 建设状态,
*
from tb