We will start with a simple report that shows multiple metrics for the same business object. Let's say we need to show the number of products and the total price for each order. Take a look at the query below:
COUNT(ProductID) AS Products,
SUM(UnitPrice * Quantity) AS TotalPrice
GROUP BY OrderID;
SUM() in two separate columns to show two different metrics for the same business object (i.e., for the same order). In this case, we used the
OrderItems table to show the number of line items and the total price for each order. Note that we use the
GROUP BY statement to compute metrics for different orders in one query.