I need a help to solve following interesting problem for me.
I've 2 id-name tables:
*************** *************** *********
ct (customers_tabl e)
------------------------------
id name
1 Alice
2 Bob
3 Carl
4 John
*************** *************** *********
*************** *************** *********
ft (fruits_table)
-----------------------------
id name
1 Apple
2 Banana
3 Apricot
*************** *************** *********
And 3rd table that consists of data that tells us which customer bought which fruit and how much. For example:
*************** *************** *********
ot (orders_table)
------------------------------
id ct_id ft_id mass
1 1 1 12
2 1 2 10
3 2 1 5
4 3 3 6
5 1 3 13
6 1 1 5
7 2 3 15
8 3 2 4
9 3 2 11
*************** *************** *********
I need the result of total bought fruits, like a following table:
*************** *************** *************** *************
Cust_name Apple Banana Apricot
Alice 17 10 13
Bob 5 0 15
Carl 0 15 6
John 0 0 0
*************** *************** *************** *************
Beforehand thank you very much for your help creating the latter dynamic table...
I've 2 id-name tables:
*************** *************** *********
ct (customers_tabl e)
------------------------------
id name
1 Alice
2 Bob
3 Carl
4 John
*************** *************** *********
*************** *************** *********
ft (fruits_table)
-----------------------------
id name
1 Apple
2 Banana
3 Apricot
*************** *************** *********
And 3rd table that consists of data that tells us which customer bought which fruit and how much. For example:
*************** *************** *********
ot (orders_table)
------------------------------
id ct_id ft_id mass
1 1 1 12
2 1 2 10
3 2 1 5
4 3 3 6
5 1 3 13
6 1 1 5
7 2 3 15
8 3 2 4
9 3 2 11
*************** *************** *********
I need the result of total bought fruits, like a following table:
*************** *************** *************** *************
Cust_name Apple Banana Apricot
Alice 17 10 13
Bob 5 0 15
Carl 0 15 6
John 0 0 0
*************** *************** *************** *************
Beforehand thank you very much for your help creating the latter dynamic table...
Comment