找回密码
 立即注册

QQ登录

只需一步,快速开始

许文龙
初级会员   /  发表于:2022-3-2 16:31  /   查看:1475  /  回复:5
5金币
请问大佬,如何实现,销售id去重,并挑选出其沟通时间最近的那条数据呢?



附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

select 销售id from t22 t1 where not exists( select 1 from t22 t2 where t2.销售id=t1.销售id and t2.沟通时间>t1.沟通时间) 再通过销售id关联t21表,

5 个回复

倒序浏览
最佳答案
最佳答案
Martian活字格认证
中级会员   /  发表于:2022-3-2 16:31:28
来自 4#
许文龙 发表于 2022-3-2 16:46
这是我的两张表,T22里面的销售id是T21里面的ID,T22里面同一个销售id有多条数据,我需要筛选出其中 沟通 ...

select 销售id from t22 t1 where not exists( select 1 from t22 t2 where t2.销售id=t1.销售id and t2.沟通时间>t1.沟通时间)

再通过销售id关联t21表,

评分

参与人数 1金币 +5 收起 理由
Lay.Li + 5 赞一个!

查看全部评分

回复 使用道具 举报
Martian活字格认证
中级会员   /  发表于:2022-3-2 16:38:36
2#
创建个视图
select * from 表 t1 where not exists( select 1 from 表 t2 where t2.销售id=t1.销售id and t2.沟通时间>t1.沟通时间)
回复 使用道具 举报
许文龙
初级会员   /  发表于:2022-3-2 16:46:58
3#
Martian 发表于 2022-3-2 16:38
创建个视图
select * from 表 t1 where not exists( select 1 from 表 t2 where t2.销售id=t1.销售id and  ...

这是我的两张表,T22里面的销售id是T21里面的ID,T22里面同一个销售id有多条数据,我需要筛选出其中 沟通时间 最近的那条数据

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
许文龙
初级会员   /  发表于:2022-3-2 17:18:36
5#
Martian 发表于 2022-3-2 16:31
select 销售id from t22 t1 where not exists( select 1 from t22 t2 where t2.销售id=t1.销售id and t2. ...

大佬厉害呀,厉害炸了
回复 使用道具 举报
Lay.Li悬赏达人认证 活字格认证
超级版主   /  发表于:2022-3-2 17:31:41
6#
感谢各位大佬的支持~
之后有问题欢迎继续发帖交流
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部