SQL Flow Field Guide

Group rows into totals

Return one summary row for each group key.

What you are trying to do

A service review compares synthetic ticket counts and effort by team.

Work through it

  1. Identify the grouping column.
  2. Trace each aggregate back to its input rows.
  3. Check which groups pass the HAVING condition.

Check your work

Each returned team has the expected count and total effort.

Practice SQL

Open in SQL Flow
SELECT Team, COUNT(*) AS TicketCount, SUM(Effort) AS TotalEffort FROM (VALUES (N'North', 20), (N'North', 15), (N'South', 40)) AS Work(Team, Effort) GROUP BY Team HAVING SUM(Effort) >= 30 ORDER BY Team;

Commands in this lesson

Next lesson Name a query step