--> 测试数据: #Job
if object_id('tempdb.dbo.#Job') is not null drop table #Job
create table #Job (JobID int,jobCorporation int,JobCount int,JobStart datetime,JobBack int)
insert into #Job
select 1,11,0,'2004-4-7',1 union all
select 2,11,0,'2005-4-4',1 union all
select 3,22,0,'2005-4-4',1 union all
select 4,22,0,'2005-4-4',1 union all
select 5,22,0,'2005-4-4',1
select * from #Job as t where not exists (select 1 from #Job where jobCorporation=t.jobCorporation and JobID<t.JobID)
/*
JobID jobCorporation JobCount JobStart JobBack
----------- -------------- ----------- ----------------------- -----------
1 11 0 2004-04-07 00:00:00.000 1
3 22 0 2005-04-04 00:00:00.000 1
*/
本文深入探讨了SQL数据清理的必要性和方法,通过实际案例展示了如何使用SQL语句高效地去除重复数据、过期记录及冗余信息,旨在提升数据库性能与数据质量。重点介绍了数据过滤、聚合与分组技巧,以及如何利用窗口函数进行复杂数据操作。
1万+

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



