我正在尝试运行此查询,但我得到“ORA-00904:“Z1”。“LONGITUDE”:无效标识符”
有没有办法重写它,以便我可以访问存在子查询中的该列?或者通常有更好的方法来实现我想要做的事情?
谢谢
select zip, count(UNIQUE address_id) LOCATIONS
from records
inner join addresses a using(address_id)
inner join zip_coords z1 using(zip)
where exists
(
select 1 from (
select distance(z1.latitude, z1.longitude, z2.latitude, z2.longitude) d
from zip_coords z2
where z2.zip in (
select zip from available_zips
)
) where d <= 50
)
GROUP BY ZIP