Fundamentals of Data Analysis Count signups from country

# 13. Count signups from country

"That’s so cool that we helped that user to log in, she indeed purchased a subscription, so awesome! But I still want to know how many users signed up from Germany " said Gessica.

So far we’ve learned how to filter all user records from Germany . Instead of counting all records by hand, we can ask SQL to count it for us. Here’s the query:

``````SELECT
COUNT(*)
FROM users
WHERE
country = 'de'
``````

As you can see it’s our normal query to select all records but instead of selecting all columns (*) we use SQL aggregate function COUNT.

## Aggregate functions

It’s helpful to think about the query above as a usual `SELECT *` query which filters all records and then aggregates them. Instead of printing all records, it gives us a single number, aggregated value, calculated from all filtered records. SQL provides an aggregate function to count, sum, calculate min/max/average values, and more. Later in the course, we’ll use these functions to answer questions like “Min/max/average user age”, “Average revenue per user” and so on.

Let’s look closer at function syntax: `COUNT(*)`. `COUNT` is a function name and `*` is the argument of a function. Usually, the argument is a column name or a wildcard symbol `*` (meaning all columns). Here’s another example of an aggregate function: `MIN(age)`:

``````SELECT
MIN(age)
FROM users
WHERE
country = 'de'
``````

This query filters users from Germany and then it aggregates all of those users by finding the one with minimum age and printing it for us. Aggregate functions are vital for reporting in Marketing or Product Management – we’re measuring a number of signups, sums or averages of revenues. We’ll see many examples of aggregate functions in the SQL Habit course. It’s time for practice!