﻿ AdventureWorks: Calculate the total freight paid by each customer

# AdventureWorks Database: Calculate the total freight paid by each customer

## SQL Query - AdventureWorks: Exercise-7 with Solution

7. From the following table write a query in SQL to calculate the total freight paid by each customer. Return customerid and total freight. Sort the output in ascending order on customerid.

Click to view Full table

Sample Solution:

``````SELECT customerid,sum(freight) as total_freight
group by customerid
ORDER BY customerid ASC;
``````

Sample Output:

```customerid|total_freight|
----------+-------------+
11000|     206.2249|
11001|     159.5971|
11002|     202.8511|
11003|     203.4823|
11004|     204.9003|
11005|     203.0334|
11006|     202.9759|
11007|     205.2751|
11008|     202.6578|
11009|     202.2833|
11010|     202.2011|
11011|     203.3261|
11012|       2.0315|
11013|       2.8490|
11014|       3.4613|
11015|      62.5243|
...
```

## Practice Online

Contribute your code and comments through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿