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 Reporting with SQL Aggregate and Numeric Functions Review: Aggregate and Numeric Functions

Possible Wrong Answer?

image

What is the result you should expect from the following query?

SELECT COUNT(platform) FROM games;

Hi, Isn't the answer to this question 4? I've chosen 4 and it said I'm wrong. If it isn't could you tell me why?

regards,

Jaeson

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, jaesonshin! No, it's not incorrect. Remember, that you're counting the number of platforms listed in that table. And there are only two platforms listed. There is only "NULL" and "Xbox One". Thus, the answer should be two. If you were counting the names of the games then it would be 4.

Hope this helps! :sparkles:

Oh.. yes. COUNT() does not count NULL.

Thank you, Jennifer!!

Jaeson

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

jaesonshin That's exactly correct! It does not count NULL so in this case, you get a result of 2 because it counts "Xbox One" twice. However, had you done COUNT(DISTINCT(platform)) you would get a result of 1 because NULL doesn't count at all and the "Xbox One" is repeated :smiley: