Skip to content

Instantly share code, notes, and snippets.

@wildjcrt
Forked from tka/test.rb
Created June 25, 2014 01:16
Show Gist options
  • Save wildjcrt/bf0db7b5bef9e0e995aa to your computer and use it in GitHub Desktop.
Save wildjcrt/bf0db7b5bef9e0e995aa to your computer and use it in GitHub Desktop.
sql = "select *, (select count(books.id) from books where books.authorsid=authors.id) as books_count from authors "
authors = Author.find_by_sql(sql)
authors.first.books_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment