Reputation: 7866
I would like to compare and get only stations which are within a distance range ONE TO THE OTHER. Let say I have 3 stations A-B-C they all have a position x-y-z. I would like to get the stations that are distant from 30 meters (I have a function to compute the distance so let's call it distance(x,y)).
SELECT * FROM Station WHERE distance(Station1, Station2) < 30
My problem is how can you compare distance of two different rows Station1 and Station2?
Thanks!!!
Upvotes: 0
Views: 153
Reputation: 174397
You could do something like this:
select a.*
from station a
inner join station b
on distance(a.station_id, b.station_id) < 30;
Upvotes: 1