Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Querying Relational Databases Subqueries Review and Practice

Sean Flanagan
Sean Flanagan
33,235 Points

Book count

Hi. I'm struggling to come up with an answer to this one. My code is incomplete, but I can't think of an answer despite having watched all the videos in this stage twice.

This is how far I got:

-- Generate a report that lists the book titles from both locations and count the total number of books with the same title.

SELECT title FROM books_north
WHERE title IN (
  SELECT title FROM books_south
  WHERE

I'd appreciate any tips please.

1 Answer

Steven Parker
Steven Parker
229,783 Points

Here's a few hints:

  • you might not need a WHERE clause
  • you could create a UNION ALL of the two tables and use it as a derived table
  • you may want to GROUP BY the titles
  • the COUNT function could be handy

Super helpful