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

Sipann A.
Sipann A.
30,234 Points

SQL - Querying Relational databases - Challenge Task #3

Hello, I get a "Bummer! Your query didn't select the FirstName, LastName and SaleAmount!" on this question. My code is:

SELECT SalesRep.FirstName, SalesRep.LastName, SUM(Sale.SaleAmount) 
FROM SalesRep 
INNER JOIN Sale ON SalesRep.SalesRepId = Sale.SalesRepId 
GROUP BY SalesRep.LastName;

As I do not have access to the database "behind", I can't check by myself but this code provides with a return set: Indira Gupta 215350.00 Jordan Jackson 128400.00 Mike Jones 211200.00 ...

I have tried joining FirstName and LastName in one column to group them by full name, but does not seem to be what I'm expected to do either. What am I missing? Thanks for any help provided!

can you paste the link to the challenge ... I think I see the problem

Hello

you need to group by the item(s) you are aggregating on.

2 Answers

Sipann A.
Sipann A.
30,234 Points

@markmneimneh Thanks for your answer. Yes, I grouped only by LastName not to overweight my code on this request. However, when aliasing FirstName and LastName as full_name and grouping them by full_name, I can see that no SalesRep share the same LastName. I guess it is not an issue here. I've tried your solution anyway (I assumed you meant: "try GROUP BY SalesRep.LastName, SalesRep.FirstName;" rather than "try GROUP BY SalesRep.LastName, SalesRep.LastName;"). I also corrected the name of the columns "SalesRepID" vs "SalesRepId" ... but nothing changes...

Sipann A.
Sipann A.
30,234 Points

Just in case anyone gets stuck like I did... Forget about grouping and summing results for this query. Not part of what's expected. Thanks markmneimneh for your support!

Thank you Sipann!