Skip to content

Instantly share code, notes, and snippets.

@kevinzen
Forked from tcocca/gist:663089
Created November 4, 2010 22:24
Show Gist options
  • Save kevinzen/663316 to your computer and use it in GitHub Desktop.
Save kevinzen/663316 to your computer and use it in GitHub Desktop.
SELECT leads.id,
(SELECT COUNT(*) FROM searches WHERE lead_id = leads.id) AS searches_count,
(SELECT COUNT(*) FROM rental_searches WHERE lead_id = leads.id) AS rental_searches_count,
COALESCE((searches_count + rental_searches_count), 0) as total
FROM leads
WHERE leads.id = 35
# Unknown column 'searches_count' in 'field list'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment