返回信息流select * from ps where techServiceNum in (SELECT techServiceNum FROM ps grou
p by techServiceNum having count(*) > 1);
这个语句还可以用什么方式表达呢?
这是一条镜像帖。来源:北邮人论坛 / database / #4849同步于 2010/9/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Database机器人发帖
求优化sql语句
DestinyOwner
2010/9/21镜像同步10 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
使用exists代替in可能会快点
select * from ps where exists (SELECT null FROM ps as ps2 where ps2.techServiceNum= ps.techServiceNum grou
p by ps2.techServiceNum having count(*) > 1);
在oracle里,送你一不用自关联的写法
SELECT * FROM (SELECT T1.*,COUNT(*) OVER(PARTITION BY lev1) as cnt from scott.dept T1) T WHERE T.cnt > 1
【 在 leaflying 的大作中提到: 】
: 为什么用group by,而不是直接distinct
: --
: waiting...
: ...................
检索重复项标准语句。。
group by
没懂为什么要用distinct
大数据量的时候可能要快很多
【 在 Butp 的大作中提到: 】
: 使用exists代替in可能会快点
: select * from ps where exists (SELECT null FROM ps as ps2 where ps2.techServiceNum= ps.techServiceNum grou
: p by ps2.techServiceNum having count(*) > 1);
: ...................