From the course: SQL for Non-Programmers

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Solution: Aggregate functions solved

Solution: Aggregate functions solved - SQL Tutorial

From the course: SQL for Non-Programmers

Solution: Aggregate functions solved

How did you do in your SQL challenge on aggregate functions? You were tasked with preparing a sales report by state, revealing the priority states for the business. Priority states are those with six employees assigned and that have brought in over 40,000 in sales. The report should be ordered from largest to smallest sales so that we can easily see the ranking. Your first challenge with querying the unique number of employees working for each state. Your query should look like this. SELECT customer state, comma. COUNT DISTINCT employee ID as employee count FROM oliveoil.sales GROUP BY customer state. If we execute the query, we should see an output with two columns, customer states and the count of employees for each, which tends to be around 5 or 6. We have not specified an ORDER BY clause, so SQLite is defaulting to an alphabetical order by state, starting with Alabama. Be careful here. If you forgot to include the distinct keyword in your count function, then you will notice the…

Contents