sql 查询重复记录2
sql 查询重复记录2
http://blog.csdn.net/tobeistdo/archive/2009/11/11/4797545.aspx
========第一篇=========
在一张表中某个字段下面有重复记录,有很多方法,但是有一个方法,是比较高效的,如下语句:
select data_guid from adam_entity_datas a where a.rowid > (select min(b.rowid) from adam_entity_datas b where b.data_guid = a.data_guid)
如果表中有大量数据,但是重复数据比较少,那么可以用下面的语句提高效率
select data_guid from adam_entity_datas where data_guid in (select data_guid from adam_entity_datas group by data_guid having count(*) > 1)
此方法查询出所有重复记录了,也就是说,只要是重复的就选出来,下面的语句也许更高效
select data_guid from adam_entity_datas where rowid in (select rid from (select rowid rid,row_number()over(partition by data_guid order by rowid) m from adam_entity_datas) where m <> 1)
目前只知道这三种比较有效的方法。
第一种方法比较好理解,但是最慢,第二种方法最快,但是选出来的记录是所有重复的记录,而不是一个重复记录的列表,第三种方法,我认为最好。
========第二篇=========
select usercode,count(*) from ptype group by usercode having count(*) >1
========第三篇=========
找出重复记录的ID:
select ID from
( select ID ,count(*) as Cnt
from 要消除重复的表
group by ID
) T1
where T1.cnt>1
删除数据库中重复数据的几个方法
数据库的使用过程中由于程序方面的问题有时候会碰到重复数据,重复数据导致了数据库部分设置不能正确设置……
方法一
declare @max integer,@id integer
declare cur_rows cursor local for select 主字段,count(*) from
相关文档:
1、到微软官方去下载新的驱动,下载地址如下:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9
官方文档有描述:
Refer to the documentation that is installed with the driver for a description of the new features in this ......
数据字典dict总是属于Oracle用户sys的。
1、用户:
select username from dba_users;
改口令
alter user spgroup identified by spgtest;
2、表空间:
select * from dba_data_files;
select * from dba_tablespaces;//表空间
select tablespace_name,sum(bytes), sum(b ......
示例:
传入多个Email地址,通过每个Email地址间的','分隔符,将各Email地址分开。
SELECT * from dbo.uf_Split('aa@aa.com,bb@bb.com,cc@cc.com,dd@dd.com',',');
查询结果:
subid autoid
aa@aa.com 1
bb@bb.com 2
cc@cc.com 3
dd@dd.com 4
下面是[uf_Split]方法的具体实现:
CREATE ......
用SQL查询分析器操纵Excel及导入导出数据
http://www.delphibbs.com/keylife/iblog_show.asp?xid=32983
SQL SERVER 和EXCEL的数据导入导出
通常的方法是使用图形界面的dts工具,但发觉有些使用命令行界面的方式更简单
1、在SQL SERVER里查询Excel数据:
-- ======================================================
SE ......