Skip to content

Instantly share code, notes, and snippets.

Created Feb 20, 2021
What would you like to do?
Legacy Query
FROM (select as id,
when active_job.location isnull
then :radius
when l1.location isnull
then :radius
else st_distance(l1.location, active_job.location) end as dist,,
similarity(j1.title, active_job.title) as close,
from job_tb j1
join b2b_tb b1 on = j1.b2b_id
left outer join location_tb l1 on j1.location_id =,
(select as id,
title as title,
location as location,
source as source,
category_id as category_id,
company as company
from job_tb j
join b2b_tb b on j.b2b_id =
left outer join location_tb l on j.location_id =
where = :job_id) active_job
where (j1.source not in ('Free sources'))
and j1.finished != true
and l1.addr_zip notnull
and !=
and j1.category_id = active_job.category_id
order by close desc, dist, j1.updated_at desc) data
where dist <= :radius
and data.close > similarity
order by data.close desc
limit :count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment