同一个表里
ID Name price
1 12 1.1
2 12 5
3 13 2
4 13 3
5 14 4
6 14 1.2如何得出 price之差 <0.2 都认为是符合的记录
比如上面的结果应该是
1 12 1.1
6 14 1.2
ID Name price
1 12 1.1
2 12 5
3 13 2
4 13 3
5 14 4
6 14 1.2如何得出 price之差 <0.2 都认为是符合的记录
比如上面的结果应该是
1 12 1.1
6 14 1.2
调试欢乐多
from tab a
where exists(select *
from tab b
where abs(a.price-b.price)<0.2 and a.id <> b.id)
oracle处理速度非常慢,有没有效率高点的语句?
from (select id,
name,
price,
LAG(price, 1, price + 1) OVER(ORDER BY price) as gg,
lead(price, 1, price + 1) OVER(ORDER BY price) as ff
from bbb) tab1
where abs(tab1.price - tab1.gg) < 0.2
or abs(tab1.price - tab1.ff) < 0.2