T-SQL: Subquery with Sum

Please see my other Database Development articles.

Performing a subquery while Sum-ming a column

In this article I will demonstrate how to use a subquery with SUM() to return parent records and related child records while aggregating currency amounts.

First, I’ll start with a a couple customer records, each with two order records with a total.

Next, I’ll return the same customer records, each with a grant total of their order total from their order records.