Skip to content

Instantly share code, notes, and snippets.

@jmhodges
Created June 2, 2009 00:16
Show Gist options
  • Save jmhodges/121902 to your computer and use it in GitHub Desktop.
Save jmhodges/121902 to your computer and use it in GitHub Desktop.
SELECT count(DISTINCT "searches".id) AS count_distinct_searches_all
FROM "searches"
LEFT OUTER JOIN "queries" ON "queries".id = "searches".query_id
INNER JOIN "tasks" ON tasks.search_id = searches.id
WHERE
(
(
(
(
NOT exists(
SELECT search_results.id FROM search_result_ownerships, search_results
WHERE searches.id = search_results.search_id
AND search_result_ownerships.search_result_id = search_results.id
AND search_result_ownerships.search_engine_id = 7
)
)
AND (tasks.job_id IS NOT NULL)
)
AND ("searches".project_id = 20)
)
AND ("searches".project_id = 20)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment