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(product_id) AS products,
SUM(unit_price * quantity) AS total_price
GROUP BY order_id;
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
order_items 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.