Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select "author".id, "author".name, count("author_book".book_id) as count_books
- from "author"
- left join "author_book" on "author_book".author_id="author".id
- where (
- select count(books.author_id)
- from "author_book" as books
- inner join author_book as soauthor_book on soauthor_book.book_id=books.book_id and soauthor_book.author_id <> "author".id
- where books.author_id="author".id
- ) = 0
- group by "author".id, "author".name
- having count("author_book".book_id) > 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement