私は顧客グループのテーブルを持っていますが、私はグループの名前(およびNotesと呼ばれる別の値)を選択したいが、グループではそれもできないグループ全体で同じ名前とメモの価値があります。sqlのidでグループから名前を取得する方法
select cg.idCustomerGroup,
sum(case when c.type = 'child' then 1 else 0 end) as Children,
sum(case when c.type = 'adult' then 1 else 0 end) as Adults,
sum(case when c.type = 'senior' then 1 else 0 end) as Seniors
from CustomersGroups cg
inner Join CustomersInGroup cig
on cg.idCustomerGroup = cig.idCustomerGroup
inner Join Customers c
on c.idCustomer = cig.idCustomer
Group by cg.idCustomerGroup
と 'cg.idCustomerGroup、Notes'によってグループが動作しませんか?いくつかのサンプルテーブルデータと期待される結果を追加できますか? – jarlh