Citation :
Select l.abn_id, l.ligno, count(*) as seq into #t2
from abonnement_ligne l left outer join abonnement_ligne as r on l.abn_id = r.abn_id and l.ligno >= r.ligno group by l.abn_id, l.ligno having count(*) <= 5
order by l.abn_id;
select distinct u.usr_nom,
u.usr_prenom,
u.usr_telephone,
u.usr_email,
u.usr_adresse,
u.usr_code_postal,
u.usr_ville,
u.usr_date_naissance,
u.usr_sexe,
a.abn_sms,
a.abn_mail,
a.abn_newsletter,
l.lignomcommercial
from utilisateur u inner join abonnement a on u.usr_id=a.usr_id inner join abonnement_ligne al on a.abn_id=al.abn_id inner join #t2 on al.abn_id=#t2.abn_id
inner join ligne l on l.ligno = #t2.ligno
where usr_login like ('%@%')and (abn_mail =1 or abn_newsletter =1 )
and al.abn_id in (Select abn_id
from #t2) and al.ligno in (select ligno from #t2)
order by usr_email;
|