title: Get books with 2 or more authors in SQL
body: <p>So I've a problem where I want to get books which have more than two authors. Im new at T-SQL so, I dont get it so well yet..</p>
  
  <p>My tables looks like this</p>
  
  <p>Book table:</p>
  
  <pre><code>     BOOK
  ---------------
  book_id | title
  ---------------
     1    |   A
     2    |   B
  </code></pre>
  
  <p>Author table:</p>
  
  <pre><code>     AUTHOR
  ----------------
  author_id | name
  ----------------
       1    | Nick
       2    | Clem
       3    | John
  
  </code></pre>
  
  <p>Book-Author table:</p>
  
  <pre><code>  BOOK_AUTHOR
  --------------------
  book_id |  author_id
  --------------------
     1    |     1
     1    |     2
     2    |     3
  </code></pre>
  
  <p>So, as you are seeing, the expected output I want is this:</p>
  
  <pre><code>
   Author_id |  title  |       author_name
  ------------------------------------------
      1    |    A    | Nick
      2    |    A    | Clem
  </code></pre>
  
  <p>Here is the SQL Query Im executing:</p>
  
  <pre><code>SELECT a.Id, a.name, b.title, count(ba.idBook)
  FROM BookAuthors as ba
  JOIN Author as a
  ON ba.IdAuthor = a.Id
  JOIN book as b
  ON ba.idBook = b.id
  GROUP BY a.Id, a.name, b.title
  HAVING count(ba.idBook) &gt; 1
  </code></pre>
  
  <p>Thanks in advance guys!</p>