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 trialEmmanuel Jimenez
21,666 PointsI dont understand this challenge.
I don't know how to complete this challenge, I'm trying this: SELECT genre, COUNT(genre) AS genre_count FROM books GROUP BY genre;
Anyone can help me?
2 Answers
ivana kantnerova
15,932 Pointstry this: SELECT genre, COUNT(*) AS genre_count FROM books GROUP BY genre;
ivana kantnerova
15,932 Pointsor .. if the tables are books and genre, then: select genre.genre, count (*) as genre_count from genre left join books on genre.id = books.genre_id group by genre.genre
Emmanuel Jimenez
21,666 PointsEmmanuel Jimenez
21,666 PointsYou want to count the genres into the field 'genre'? Isn't work because COUNT() retrieve the total of rows matched with the expression parse it. So you need to use the comodin ( * ). So will match all the rows in the field 'genre' because you're saying get all the values into the field 'genre' literally. So you updated sql command will be: SELECT genre, COUNT(*) AS genre_count FROM books GROUP BY genre;