私は顧客テーブルを持っています:
id name
1 customer1
2 customer2
3 customer3
およびトランザクションテーブル:
id customer amount type
1 1 10 type1
2 1 15 type1
3 1 15 type2
4 2 60 type2
5 3 23 type1
クエリで返したいのは次の表です
name type1 type2
customer1 2 1
customer2 0 1
customer3 1 0
これは、customer1がtype1の2つのトランザクションとtype2の1つのトランザクションを行ったことを示しています。
この結果を取得するために使用できるクエリはありますか、それとも手続き型コードを使用する必要がありますか?