У меня есть следующий стол:
Case with columns > ID,ResponsibleID
Action with columns > ID,CaseID,Action
Я хочу получить список всех ответственных лиц с указанием их количества и общего количества действий по всем этим делам.
Это может быть запрос, если он работает, но он не
Select
Case.ResponsibleID,
CaseCount=count(*),
--how can i tell sql that this is the CaseID sublist of the group?
--It would be possible with a subquery, but i rather not do that for performance reasons.
--the real query gets the caseID list from a table 3 or 4 joins later.
ActionCount=(select count(*) from Action where CaseID in Case.CaseID)
From Case
Group by ResponsibleID