Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Bruce McMinn
Bruce McMinn
10,029 Points

Subqueries Review & Practice # 1 Clunky Answer

So question 1 asks for a list of all titles and a count of duplicate books. That sounds like a column of words and another column with a single numeric entry. Can I combine these two making a derived table of either?

-- a list of all books, no duplicate titles

SELECT bn.title FROM books_north AS bn
SELECT bs.title FROM books_south AS bs
SELECT bs.title FROM books_south AS bs;


-- a complicated way to get the number 12

SELECT COUNT(*) AS BooksWithMultipleCopies FROM 
(SELECT COUNT(*) as book_num
FROM (SELECT title FROM books_north 
      SELECT title FROM books_south)    
GROUP BY title
HAVING book_num>1);

I'm guessing that there isn't a good join criteria??

Steven Parker
Steven Parker
220,416 Points

Actually it sounds like it could be done easily with a join. Could you share a link to the course page so the original instructions can be viewed?

Bruce McMinn
Bruce McMinn
10,029 Points

Sure thing Steven, thanks for your help.

The link to the database is: https://teamtreehouse.com/sql_playgrounds/522#/queries/670ffc6e-68f8-4117-aeda-a3bd5d37d4b3

and it is at: Databases/Querying Relational Databases/Subqueries/Review and Practice.

Do you know how I get a question's subject that specific when I ask it? As in page view