删除结果集中字段重复的方法
--> 測試數據: #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
*/
?
總結
以上是生活随笔為你收集整理的删除结果集中字段重复的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 程序员最新研究发现【西安楼市 2011
- 下一篇: 一个可变的C++字符序列是5 0新增的