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 Counting Results

Some hints to make up for some limited/bad diagnostic messages in the challenge answer engine..

If any of you have gotten this far (and are still struggling) let me advise you that

some of the Bummer! messages that say something about your "count" being wrong

or unhelpful messages saying error near such and such

will probably not be as helpful in getting to the right answer as

re-watching the video that immediately precedes the challenge question.


This SQL Reporting course (unlike many at Treehouse) does really try to provide

a reasonably tight "coupling" between the SQL code presented in the videos

and what SQL code is expected in the challenges (as least better than using google

to search for relevant SQL code --since their are many different SQL language variations possible).


This course tends toward using SQLite mostly,

but the cheat sheets it provides (in lieu of not having a downloadable zip file for the course)

do include links to multiple types/flavors of SQL:

https://github.com/treehouse/cheatsheets/blob/master/sql_basics/cheatsheet.md

https://github.com/treehouse/cheatsheets/blob/master/reporting_with_sql/cheatsheet.md


A few selected "hints" for the SQL code of various challenges in this aggregate and number functions section:

Link to challenge:

https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/counting-groups

SELECT genre, COUNT(*) AS genre_count FROM books GROUP BY genre;
SELECT COUNT(DISTINCT genre) AS total_genres FROM books;

Link to challenge:

https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/calculating-the-minimum-and-maximum-values

SELECT MIN(rating) AS star_min, MAX(rating) AS star_max FROM reviews WHERE movie_id = 6;

Link to challenge:

https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/performing-math

SELECT name, ROUND(price/1.4,2) AS price_gbp FROM products;

Link to challenge:

https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/averaging-values

SELECT AVG(rating) AS average_rating FROM reviews WHERE movie_id = 6;
SELECT SUM(rating) AS starman_total_ratings FROM reviews WHERE movie_id = 6;

More hints for the next (data and time) section can be found here:

https://teamtreehouse.com/community/some-hints-to-make-up-for-some-limitedbad-diagnostic-messages-in-the-challenge-answer-engine-2

Counting group challenge answer below.

Challenge Task 1 of 2 <br/> select genre, COUNT(*) as genre_count from books GROUP BY genre; <br> Challenge Task 2 of 2 <br> select COUNT(DISTINCT genre) as total_genres from books;

James thanks so much for the information.