マトリックス スタイルのレポートのクエリを作成するのに助けが必要です。
私のデータは次の形式です
id body_part incident_type1 incident_type2 incident_type3
1 head PPE null null
2 ankle Unsafe Act Facility null
3 hand null null null
4 head Facility PPE Unsafe Act
行が体の部分になり、列がインシデントの種類になるようにします。Incident_type1 が null の場合、「n/a」列にカウントが必要です。ただし、incident_type2 および/または 3 が null の場合、それらを "n/a" 列に含めたくありません。
Facility Unsafe Act PPE N/A
ankle 1 1 0 0
hand 0 0 0 1
head 1 1 2 0