現在、クエリを実行しています:
select table1.columnA as Barrier_1,
table2.columnB as Action_1,
from table2
join table1 on table2.PrimKey = table1.PrimKey
where table1.columnA is not null
and table2.columnB is not null
group by table1.columnA, table2.columnB
order by table1.columnA
テーブルを返します:
Barrier_1 Action_1
____________________
01 | 01
01 | 02
02 | 01
02 | 03
02 | 04
03 | 02
03 | 03
04 | 01
05 | 04
そして、私がやりたいことは、バリアごとの各アクションの割合を計算することです:
Barrier_1 Action_1 Percent_1
________________________________
01 | 01 | 60%
01 | 02 | 40%
02 | 01 | 20%
02 | 03 | 10%
02 | 04 | 70%
03 | 02 | 20%
03 | 03 | 80%
04 | 01 | 100%
05 | 04 | 100%
各アクションは、バリアごとに複数回表示される可能性があることに注意してください。
したがって、各バリアには独自の一連のアクションがあります。たとえば、バリア 1 は合計 5 つのアクションを持つことができます (2 つがアクション 02 で、3 つがアクション 01 です)。