From the course: SQL: Data Reporting and Analysis

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Use GROUP BY with count

Use GROUP BY with count

- [Instructor] Sometimes you want to return information about a table rather than just returning a subset of information from within the table. So for instance, you might want to know how many times something occurs or how many rows you've got. Let's have a look at the address table. If all you want is a count of rows, you can do that with count star, like so. We hit go and it gives us the number 603, which means there's 603 rows in our table. Now, just a quick note on the asterisk, where we have seen that until now it's been like this, hasn't it? Select star from address, and that has meant select all fields. But when we use it with select count, it can be read really as select the count of all rows, in a way. We can limit our count to just one field. So if we take the address field which is the street address, generally it gives the same result and this is 603. But I don't know if you noticed, there was a field…

Contents