Insert into
[PisCh].[dbo].[same_sfz] ([rensfzhm]
,[counter])
SELECT renSfzhm,COUNT(*)
FROM [pis_base_xj].[dbo].[jc_pjb]
where bdlxCode<>'70' and bdlxCode<>'81' and renSfzhm is not null
group by renSfzhm having COUNT(*)>1
insert into [PisCh].[dbo].[SfzCaculate1]
( [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,[RenSfzhm1]
,[S2])
SELECT [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,b.RenSfzhm
,b.bdlxCode
--,b.renhkszdsm,b.bdlxCode
FROM [PisCh].[dbo].[same_sfz] a inner join [pis_base_xj].[dbo].[jc_pjb] b
on a.rensfzhm=b.renSfzhm
--where b.rensfzhm='520102195409141224'
order by a.rensfzhm
[PisCh].[dbo].[same_sfz] ([rensfzhm]
,[counter])
SELECT renSfzhm,COUNT(*)
FROM [pis_base_xj].[dbo].[jc_pjb]
where bdlxCode<>'70' and bdlxCode<>'81' and renSfzhm is not null
group by renSfzhm having COUNT(*)>1
insert into [PisCh].[dbo].[SfzCaculate1]
( [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,[RenSfzhm1]
,[S2])
SELECT [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,b.RenSfzhm
,b.bdlxCode
--,b.renhkszdsm,b.bdlxCode
FROM [PisCh].[dbo].[same_sfz] a inner join [pis_base_xj].[dbo].[jc_pjb] b
on a.rensfzhm=b.renSfzhm
--where b.rensfzhm='520102195409141224'
order by a.rensfzhm
本文介绍了一个具体的SQL数据整合案例,通过使用SQL语句从不同表中抽取数据,并进行汇总统计,特别是针对身份证号码重复的情况进行了专门处理。此案例展示了如何进行数据清洗及整合,为后续的数据分析提供支持。
1936

被折叠的 条评论
为什么被折叠?



