/*
select n.nuage_email, nuage_date_inscription as date_inscription
from nuage n
  left outer join membre m on n.nuage_email = m.membre_email
where m.membre_id is null
and nuage_optin = 1
and nuage_date_inscription >= '2008-05-23 14:39:56'
-- group by substring(date_inscription, 1, 7)
-- order by substring(date_inscription, 1, 7)
union
-- select count(*)
-- select substring(date_inscription, 1, 7), count(*)
select m1.email, date_inscription
from membre_v1 m1
  left outer join membre m on m1.email = m.membre_email
  left outer join nuage n on n.nuage_email = m1.email
where m.membre_id is null
and n.nuage_email is null
-- and source in ('zoomcontact', 'warmup')
and m1.optin = 1
;
*/

select substring(date_inscription, 1, 7), count(*)
from
(
select n.nuage_email, nuage_date_inscription as date_inscription
from nuage n
  left outer join membre m on n.nuage_email = m.membre_email
where m.membre_id is null
and nuage_optin = 1
and nuage_date_inscription >= '2008-05-23 14:39:56'
and nuage_source not in ('zoomcontact', 'warmup')

union

select m1.email, date_inscription
from membre_v1 m1
  left outer join membre m on m1.email = m.membre_email
  left outer join nuage n on n.nuage_email = m1.email
where m.membre_id is null
and n.nuage_email is null
and m1.optin = 1
and source not in ('zoomcontact', 'warmup')
) as t
group by substring(date_inscription, 1, 7)
order by substring(date_inscription, 1, 7)
