Public Sub distinctCount() '求Col列中StartRow到EndRow范围中不重复的个数 '本例是计算标题为sheet1的Excel表中的A1:A240的不重复值的个数 '修改下面四行的结尾值 Dim sheetsCaption As String: sheetsCaption = "Sheet1" Dim Col As String: Col = "A" Dim StartRow As Integer: StartRow = 1 Dim EndRow As Integer: EndRow = 240 '以下固定 Dim Count As Integer: Count = 0 With Sheets(sheets...[ 查看全文 ]
采用的是下面的方法可删除,假设重复的是test数据库中的title字段 代码如下: create table bak as (select * from test group by title having count(*)=1); insert into bak (select * from test group by title having count(*)1);  ...[ 查看全文 ]
方法一 declare @max integer,@id integer declare cur_rows cursor local for select 主字段,count(*) from 表名 group by 主字段 having count(*) 1 open cur_rows fetch cur_rows into @id,@max while @@fetch_status=0 begin select @max = @max -1 set rowcount @max delete from 表名 where 主字段 = @id fetch cur_rows into @id,@max end close cur_rows set rowcount 0 方法二 有两个意...[ 查看全文 ]