---一道SQL题目,向所有CSDN高手请教-------------

cefriend 2008-02-27 02:38:12
求一SQL语句实现数据表之间的去重复项

如有一表AT 中有四个字段

a b c d 其中 a字段,b字段,c字段为联合主键
数据如下

a b c d
1 11 22 aa
1 22 22 bb
1 33 22 cc
2 11 22 dd

有另一张表AT_Temp临时表
也有四个个字段

a b c d 其中 a字段,b字段,c字段为联合主键
数据如下
a b c d
1 22 22 bb
1 22 33 ff
2 11 44 gg

请问如何实现AT_Temp表中与AT表去掉重复记录并将不重复数据插入到AT表中

我如道如果只有一个主键 a 的话用

insert into AT select * from A_Temp from a not in (select a from AT) 可以做出来,但当他有三个主键
后我在后面中 and b not in (select b from AT) ... 是不可行的,并且效率低,求一好的SQL
...全文
126 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawugui 2008-02-27
  • 打赏
  • 举报
回复
匆忙中漏写表,现在才发现.多谢海阔天空.

select at_temp.* from at_temp where not exists(select 1 from at where at.a = at_temp.a and at.b = at_temp.b and at.c = at_temp.c)
zhuyx808 2008-02-27
  • 打赏
  • 举报
回复
你们写语句,我来接个分
firefox_1983 2008-02-27
  • 打赏
  • 举报
回复
晕,居然贴错地方了。
firefox_1983 2008-02-27
  • 打赏
  • 举报
回复
SELECT 
name,
classid,
counts,
classname
FROM
merchant
WHERE
counts in
(
SELECT
max(counts)
FROM
merchant
GROUP BY
classname
)
ORDER BY
counts asc
gahade 2008-02-27
  • 打赏
  • 举报
回复

insert into AT
select * from A_Temp from a
where not exists(select 1 from at where a.a=at.a and a.b=at.b and a.c=at.c)
昵称被占用了 2008-02-27
  • 打赏
  • 举报
回复
修正2楼的

select at_temp.* from at_temp where not exists(select 1 from at where at_temp.a = at.a and at_temp.b = at.b and at_temp.c = at.c)
昵称被占用了 2008-02-27
  • 打赏
  • 举报
回复
修正一楼的

insert   into   AT   
select * from A_Temp a
where not exists(select 1 from at b where a.a=b.a and a.b=b.b and a.c=b.c)
昵称被占用了 2008-02-27
  • 打赏
  • 举报
回复
insert   into   AT   
select * from A_Temp from a
where not exists(select 1 from at b where a.a=b.a and a.b=b.b and a.c=b.c)


dawugui 2008-02-27
  • 打赏
  • 举报
回复
select at_temp.* from at_temp where not exists(select 1 where at_temp.a = at.a and at_temp.b = at.b and at_temp.c = at.c)
gahade 2008-02-27
  • 打赏
  • 举报
回复

insert into AT
select * from A_Temp from a
where not exists(select 1 from at b where a.a=at.a and a.b=at.b and a.c=at.c)
内容概要:本文详细介绍了一个基于MATLAB实现的线性回归(LR)电力负荷预测项目实例,涵盖了从项目背景、模型架构、算法流程、代码实现到GUI界面设计的完整开发过程。项目通过整合历史负荷、气象数据、节假日信息等多源变量,构建多元线性回归模型,并结合特征工程、数据预处理、正则化方法(如岭回归、LASSO)和模型评估指标(RMSE、MAPE、R²等),提升预测精度与泛化能力。文中还展示了系统化的项目目录结构、自动化部署脚本、可视化分析及工程集成方案,支持批量预测与实时滚动更新,具备高度模块化、可解释性强、部署友好的特点。; 适合人群:具备一定MATLAB编程基础,从事电力系统分析、能源管理、智能电网或数据建模相关工作的工程师、研究人员及高校师生。; 使用场景及目标:①应用于城市电力调度、新能源消纳、智能楼宇用能管理等场景下的短期负荷预测;②帮助理解线性回归在实际工程项目中的建模流程、特征处理与模型优化方法;③通过GUI界面实现交互式预测与结果可视化,支持工程落地与决策辅助; 阅读建议:建议结合提供的完整代码与GUI示例进行实践操作,重点关注数据预处理、特征构造、正则化调优与模型评估部分,深入理解各模块的设计逻辑与工程封装思路,以便迁移到类似的时间序列预测任务中。

34,872

社区成员

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

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