/*
-- Premier export
select nuage_email as email, nuage_source as source, nuage_civilite as civilite, nuage_nom as nom, nuage_prenom as pernom, nuage_date_naissance as date_naissance, nuage_optin as optin
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_source not in ('zoomcontact', 'warmup')
order by nuage_date_inscription desc
limit 500000;
*/

/*
select count(*)
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_source not in ('zoomcontact', 'warmup')
and nuage_date_inscription < '2008-05-23 14:39:56'
;
-- order by nuage_date_inscription desc;

select count(*)
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 optin = 1;
*/

-- Deuxieme export
select nuage_email as email, nuage_source as source, nuage_civilite as civilite, nuage_nom as nom, nuage_prenom as prenom, nuage_date_naissance as date_naissance, nuage_optin as optin
from nuage n
  left outer join membre m on n.nuage_email = m.membre_email
  left outer join notation.hb h on n.nuage_email = h.hb_email
where m.membre_id is null
and h.hb_email 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 as email, m1.source as source, m1.civilite as civilite, m1.nom as nom, m1.prenom as prenom, m1.date_naissance as date_naissance, m1.optin as optin
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
  left outer join notation.hb h on n.nuage_email = h.hb_email
where m.membre_id is null
and n.nuage_email is null
and h.hb_email is null
and m1.optin = 1
-- and source not in ('zoomcontact', 'warmup')

