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 SQL Reporting by Example Day 2: Advanced Selecting Day 2: Review

Counting issue?

I tried

ORDER BY role

to answer this question. I'm confused. Any ideas?

Write a query to figure out how many employees are in each job role.

SELECT JOBS.ROLE, COUNT(1) FROM EMPLOYEES JOIN JOBS ON EMPLOYEES.JOB_ID = JOBS.ID ORDER BY role;

1 Answer

Steven Parker
Steven Parker
231,269 Points

The question isn't asking for any particular order, but to associate the counts with the roles you might need to use GROUP BY.

Also, without knowing the exact contents of both tables, it would be safer to refer to column(s) the same way they are referenced in the SELECT clause.