Counting the number of rows returned with COUNT.

By Alan Hylands — 1 minute read

Starting with functions.

You are probably familiar with functions if you have ever used Excel.

Functions in SQL do a similar job as the ones you’ll have encountered before. SQL functions such as COUNT, SUM, MIN, MAX and AVG all let you perform basic mathematical operations on your data.

From counting the number of rows to finding the maximum value of a certain column in your data table, SQL functions will soon become the lifeblood of your Data Analysis SQL career.

COUNT.

The COUNT function allows you to count the number of rows in your table. You can use the asterisk (*) wildcard to count everything,

e.g.

SELECT COUNT(*)
FROM WondersOfTheWorld;

Quiz Time.

The Question.

Sometimes doing a headcount in our superhero group isn't as easy as it sounds. So if we want to see just how many superheroes we have in our group, we use COUNT.

Give it a go now.

The Data.

The Editor.


Run SQL


Show Answer

The Answer.

Correct SQL:

                    SELECT COUNT(*) FROM characters;
                    

Correct Output:

Try the next lesson