-- Finds the 5 closest customers to warehouse_id = 2
select /*+ordered*/
c.customer_id,
c.cust_first_name,
c.cust_last_name
from warehouses w,
customers c
where w.warehouse_id = 2
and sdo_nn (c.cust_geo_location, w.wh_geo_location, 'sdo_num_res=5') = 'TRUE';
|