Anzahl der Abos nach Typ und Datum

Anzahl der Abos nach Typ und Datum

Anzahl Abonnements pro Abotyp, die nach dem Datum ‘xxxx-xx-xx’ begonnen bis zum  Datum ‘xxxx-xx-xx’ beendet wurden

select a.id, a.name, count(depAbo.id), count(heiAbo.id), count(posAbo.id), count(zuAbo.id) from Abotyp a
left join DepotlieferungAbo depAbo on a.id = depAbo.abotyp_id
left join HeimlieferungAbo heiAbo on a.id = heiAbo.abotyp_id
left join PostlieferungAbo posAbo on a.id = posAbo.abotyp_id
left join ZusatzAbo zuAbo on a.id = zuAbo.abotyp_id
where depAbo.start between ‘2010-01-01’ and ‘2010-12-31’ and depAbo.ende between ‘2010-01-01’ and ‘2010-12-31’
or heiAbo.start between ‘2010-01-01’ and ‘2018-12-31’ and heiAbo.ende between ‘2010-01-01’ and ‘2010-12-31’
or posAbo.start between ‘2010-01-01’ and ‘2010-12-31’ and posAbo.ende between ‘2010-01-01’ and ‘2010-12-31’
group by a.name