I have two Questions in the below query
When i tried running the query I am getting the below error in oracle
Performance issue i.e when i run the query without the IN clause i.e remove the {select * from cand_profile where postal_code in } in the below query it is taking 15 sec .How to fine tune this sql query ?
Query
select *
from cand_profile
where postal_code in (
SELECT ZIP
FROM (
SELECT
dest.ID,
dest.postal_code AS ZIP,
ACOS(SIN(RADIANS(src.latitude))*SIN(RADIANS(dest.latitude))+COS(RADIANS(src.latitude))*COS(RADIANS(dest.latitude))*COS(RADIANS(src.longitude)-RADIANS(dest.longitude)))* 3959 AS DISTANCE
FROM post_codes dest
CROSS JOIN
post_codes src
WHERE src.ID = (
SELECT ID
FROM post_codes
WHERE postal_code = '60195'
GROUP BY ID
)
AND ( dest.ID <> src.ID OR dest.ID = src.ID )
)
GROUP BY ID,ZIP,DISTANCE
HAVING DISTANCE <= 5
ORDER BY DISTANCE
))
ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *Cause:
*Action: