a project has_many tasks
a task can be assigned to many members
例如:
Project Task Member
------- ---- ------
P1 T1 M1
P1 T2 M2
P2 T1 M1
P2 T2 M2
P2 T3 M1
P3 T1 M2
我想获得以下摘要,即按成员划分的项目的最后一项任务:
------ ---
T1 3
- M1 2
- M2 1
T2 2
- M2 2
T3 1
- M1 1
如何构建 SQL?