wiki:db/queries/022
Last modified 6 years ago Last modified on 02/01/2013 06:21:34 AM

Find near-neighbor objects in a given region

  SELECT o1.objectId AS objId1 
         o2.objectId AS objId2
         spDist(o1.ra, o1.decl, o2.ra, o2.decl) AS distance
  FROM   Object o1, 
         Object o2
  WHERE  areaSpec_box(:ra1, :decl1, :ra2, :decl2)
    AND  spDist(o1.ra, o1.decl, o2.ra, o2.decl) < :distance
    AND  o1.objectId <> o2.objectId