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

sujal Khatiwada
PLUS
sujal Khatiwada
Courses Plus Student 291 Points

SQL Practice Problem

There are 267 employees and 15 with last names starting with 'A'. What does this return?

SELECT COUNT(1) FROM EMPLOYEES GROUP BY 'A';

1 Answer

Dale Severude
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 Points

The GROUP BY isn't doing anything because there is not a valid table value to group by. So the number of employees gets counted, which is 267.

To count the last names beginning with 'A' the code would look something like this:

SELECT COUNT(1)
FROM EMPLOYEES
WHERE EMPLOYEES.LAST_NAME LIKE 'A%'