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

Isaac Lau
Isaac Lau
3,767 Points

don't under question database count/distinct

i want to know what's actually it want me to do?

i though it may want how many total genres that they have (because only require as total_genres)

which i try to complete with this query select count(distinct(genre)) as totel_genres from books

endup i got total_genres = 6.

But still fail in this challenge. So i think i'm very stupid, may i know what's the correct answer? on anything that i missing?

Thank You

Steven Parker
Steven Parker
231,271 Points

To facilitate an accurate answer, please provide a link the course page you are working with.

2 Answers

Steven Parker
Steven Parker
231,271 Points

"DISTINCT" is not a function.

You just place it in front of the term it applies to, such as in: "COUNT(DISTINCT genre)".

Also, you wrote "totel_genres" with an extra "e" instead of "total_genres" (with an "a").

Isaac Lau
Isaac Lau
3,767 Points

Thank You, but i also surprise that "COUNT(DISTINCT (genre))" also work and have a same outcome.

Steven Parker
Steven Parker
231,271 Points

Yes, because parentheses can also be used to group terms together, but they don't do anything when used around a single term. But it's confusing because it looks like you're invoking a function.