Imaing we have data like this:

SQL

How could I get the total price of each “prod_type” for every “id”?

First we need to unfold the “prod_type” and “prod_price” correspondingly:

SQL

and then use “group by” to calculate total price:

SQL