用SQL删除重复记录的N种方法
用SQL删除重复记录的N种方法
2009-06-03 17:35
例如:
id name value
1 a pp
2 a pp
3 b iii
4 b pp
5 b pp
6 c pp
7 c pp
8 c iii
id是主键
要求得到这样的结果
id name value
1 a &nbs
相关文档:
ROLLUP 运算符生成的结果集类似于 CUBE 运算符生成的结果集。 下面是 CUBE 和 ROLLUP 之间的具体区别: CUBE 生成的结果集显示了所选列中值的所有组合的聚合。 ROLLUP 生成的结果集显示了所选列中值的某一层次结构的聚合。 ROLLUP 优点: (1)ROLLUP 返回单个结果集,而 COMPUTE BY 返回多个结 ......
create table #a
(
a int identity(1,1) primary key,
b int default(0) not null,
c nvarchar(20)
)
insert into #a(c)
select 'a' union all
select 'b' union all
select 'c' union all
select 'd' union all
select 'e'
select * from #a
alter table #a drop constraint DF__#a_____________b__12 ......
update CHELIANG_MINGDAN set clmd_yunxuzaizhong = cast(clmd_yunxuzaizhong/1000 as decimal(14,4)) where clmd_yunxuzaizhong is not null
update CHELIANG_MINGDAN set clmd_carweight = cast(clmd_carweight/1000 as decimal(14,4)) where clmd_carweight is not null ......
几个删除重复记录的SQL语句
2009-03-02 10:08
比如现在有一人员表 (表名:peosons)
若想将姓名、身份证号、住址这三个字段完全相同的记录查询出来
select p1.* from persons p1,persons p2 where p1.id<>p2.id &nb ......