SELECT a.country_id
,a.distributor_id
,b.organization_id
,p_yearmonth AS yearmonth
,a.visit_frequency
,a.customer_id
,COUNT(DISTINCT a.store_id) AS coverage_store
FROM init_store_scope a
,mdt_organization_distributor b
WHERE a.distributor_id=b.distributor_id(+)
GROUP BY a.country_id
,a.distributor_id
,b.organization_id
,a.visit_frequency
,a.customer_id