Skip to content

Instantly share code, notes, and snippets.

@kshahkshah
Created November 17, 2016 21:30
Show Gist options
  • Save kshahkshah/90bb8e883bc1845ed9ee3d685a3b7856 to your computer and use it in GitHub Desktop.
Save kshahkshah/90bb8e883bc1845ed9ee3d685a3b7856 to your computer and use it in GitHub Desktop.
SELECT value, id, similarity
FROM other_table
CROSS JOIN LATERAL (
SELECT similarity(master_table.value, other_table.value) as similarity
FROM master_table
ORDER BY similarity DESC
LIMIT 1
) l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment