高手请进,赐教。~~~~急急急急急急急急~~~~~~~

woolcool 2008-01-04 09:53:18
如果表中有1000条记录,
但是只有一百条记录是有效的,其他的都是重复记录,
高手赐教,如何用sql语句删除重复记录

重复记录在表中是无序的,位置不固定,
此问题困扰好长时间了
高手赐教
...全文
132 9 打赏 收藏 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
parss 2008-01-05
  • 打赏
  • 举报
回复
把表结构贴出来吧,不然不好写
中国风 2008-01-04
  • 打赏
  • 举报
回复
[code=SQL]create  table  T (id int)
insert into T select 1
insert into T select 2
insert into T select 3
insert into T select 5
insert into T select 5
insert into T select 7
insert into T select 7
insert into T select 8
insert into T select 9

go

select * from T a where (select count(1) from T where ID=a.ID)>1--显示重复记录
/*
id
-----------
5
5
7
7

(所影响的行数为 4 行)

*/

--删除
go
select distinct * into # from T

truncate table T

insert T select * from #

--查看
select * from T

/*
id
-----------
1
2
3
5
7
8
9

(所影响的行数为 7 行)

*/
[/code]
wzy_love_sly 2008-01-04
  • 打赏
  • 举报
回复
有标识列容易删除,没有就利用临时表删除
woolcool 2008-01-04
  • 打赏
  • 举报
回复
Create Table Num
(
num number;
)
;

insert into Num values(1);
insert into Num values(2);
insert into Num values(3);
insert into Num values(5);
insert into Num values(5);
insert into Num values(7);
insert into Num values(7);
insert into Num values(8);
insert into Num values(9);


这样怎么查询,不用虚拟表,就是用上边的这个真实得表,要是不用count呢
-狙击手- 2008-01-04
  • 打赏
  • 举报
回复
declare @tb table (id int)
insert into @tb select 1
insert into @tb select 2
insert into @tb select 3
insert into @tb select 5
insert into @tb select 5
insert into @tb select 7
insert into @tb select 7
insert into @tb select 8
insert into @tb select 9

select *
from @tb a
where exists (select id from @tb where a.id = id group by id having count(1) > 1)

/*

id
-----------
5
5
7
7

(所影响的行数为 4 行)
*/

select *
from @tb a
where id in (select id from @tb group by id having count(1) > 1)



/*

id
-----------
5
5
7
7

(所影响的行数为 4 行)
*/
woolcool 2008-01-04
  • 打赏
  • 举报
回复
不太懂,如何删除多余的重复记录
中国风 2008-01-04
  • 打赏
  • 举报
回复
--表T列重复有Col1\Col2
alter table T add ID int identity --新增一列
go

delete a from T a where exists(select 1 from T where Col1=a.COl1 and COl2=a.Col2 and ID<a.ID)
go
alter table drop column ID--删除新增列

---
如没有外健关联时:

select distinct * into # from T

truncate table T


insert T select * from #
wzy_love_sly 2008-01-04
  • 打赏
  • 举报
回复
declare @tb table (id int,name varchar(10))
insert into @tb select 1,'a'
insert into @tb select 2,'b'
insert into @tb select 3,'c'
insert into @tb select 5,'d'
insert into @tb select 5,'d'
insert into @tb select 7,'e'
insert into @tb select 7,'e'
insert into @tb select 8,'f'
insert into @tb select 9,'g'

select * from @tb group by id,name


1 a
2 b
3 c
5 d
7 e
8 f
9 g
wzy_love_sly 2008-01-04
  • 打赏
  • 举报
回复
declare @tb table (id int)
insert into @tb select 1
insert into @tb select 2
insert into @tb select 3
insert into @tb select 5
insert into @tb select 5
insert into @tb select 7
insert into @tb select 7
insert into @tb select 8
insert into @tb select 9

select distinct id from @tb a


1
2
3
5
7
8
9
内容概要:本文研究了计及需求侧响应的日前、日内两阶段鲁棒备用优化方法,旨在应对高比例可再生能源接入背景下电力系统中存在的不确定性问题。通过构建两阶段鲁棒优化模型,将日前调度作为第一阶段决策,日内调整作为第二阶段修正,充分考虑风电、光伏等出力波动以及负荷变化带来的影响。模型引入需求侧响应机制,利用可调节负荷参与系统备用,提升系统的灵活性与鲁棒性。采用列与约束生成(C&CG)算法对两阶段鲁棒优化问题进行求解,并通过Matlab编程实现,结合标准测试系统进行仿真分析,验证了所提方法在降低运行成本、提高可再生能源消纳能力和增强系统可靠性方面的有效性。; 适合人群:具备电力系统优化、运筹学及Matlab编程基础的研究生、科研人员及从事能源系统规划与运行的专业技术人员。; 使用场景及目标:①应用于含高比例可再生能源的电力系统调度决策,提升调度方案的鲁棒性;②为需求侧资源参与电力系统备用提供建模与求解工具;③支撑科研教学中关于两阶段鲁棒优化、C&CG算法实现的学习与实践。; 阅读建议:建议读者结合Matlab代码深入理解模型构建与求解流程,重点关注不确定性集合的刻画方式、需求侧响应的建模方法以及C&CG算法的迭代逻辑,宜配合相关优化理论资料进行系统学习。
内容概要:本文围绕掺铒光纤放大器(EDFA)的分析模型展开深入的模拟研究,重点在于利用Matlab代码实现EDFA工作过程的数值仿真,涵盖其增益特性、噪声系数以及在不同泵浦功率和波长条件下的性能表现。研究通过建立基于速率方程和传输方程的物理模型,精确描述铒离子的能级跃迁、自发辐射、受激辐射及吸收等核心物理机制,进而构建可用于光通信系统级仿真的EDFA模块。该模型不仅能够准确预测单级EDFA的输出光谱和增益平坦度,还支持对多级放大链路的级联效应进行分析与优化,具备良好的实用性、灵活性和可扩展性,为光通信系统的设计与性能评估提供了可靠的理论依据和工具支持。; 适合人群:具备一定光学通信基础知识和Matlab编程能力的研究生或科研人员,尤其适用于从事光纤通信系统仿真、光器件建模与性能优化等相关领域的工程技术人员。; 使用场景及目标:①用于高校及科研机构中关于光放大器原理的教学演示与科研分析;②支撑长距离、大容量光纤传输系统中多级EDFA链路的性能预测、噪声累积分析与优化设计;③作为典型有源光器件建模的学习案例,帮助理解复杂光电器件的数值仿真方法与物理机制。; 阅读建议:建议读者结合光通信相关理论知识,仔细研读模型的数学推导过程,并动手运行与调试所提供的Matlab代码,深入探究泵浦方式、光纤长度、掺杂浓度等关键参数对EDFA性能的影响规律,进一步可尝试将该模型集成至更大规模的光网络仿真平台中进行联合系统分析。

34,876

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧