Databases SQL Reporting by Example Day 2: Advanced Selecting Day 2: Review

olu adesina
olu adesina
22,462 Points

SQL help! i know the answer but i want to understand why

There are 267 employees and 15 with last names starting with 'A'. What does this return? SELECT COUNT(1) FROM EMPLOYEES GROUP BY 'A';

the answer is 267 but why

1 Answer

Billy Bellchambers
Billy Bellchambers
21,689 Points

GROUP BY is normally used to group by values which would differ from line to line.

Grouping by a string like this would group all records together under this same value, thus returning the full result set under the grouping of 'A'.