38ed669d-1480-42c9-a131-3541eb1020c1BAZA_REKLAM29.7cmtrue21cm0.25cmtrue2.5cm2.5cm2.5cmd0a91cad-1242-460b-89c7-3902955a12fb21cmrok1System.Int32kkSystem.Int32krSystem.Int32BAZA_REKLAMselect rok1, kk, kr from
(select year(data) as rok1, count(distinct customerId) as kk from dbo.KONTAKTY
where year(data) >=2005 group by year(data) ) t1
left join
(select year([FAKTURA DATA WYSTAWIENIA]) as rok2, count(distinct customerId) as kr
from dbo.reklama
where year([FAKTURA DATA WYSTAWIENIA]) >= 2005
AND TYP ='PŁATNA'
group by year([FAKTURA DATA WYSTAWIENIA]),typ ) t2
on t1.rok1 = t2.rok2 order by rok1 desctruerokSystem.Int32liczbaSystem.Int32liczba_klientowSystem.Int32liczba_kontaktowSystem.Int32BAZA_REKLAMselect rok, liczba, count(customerId) as liczba_klientow, sum(liczba_kontaktow) as liczba_kontaktow from
(
select customerId, rok, sum(liczba) as liczba, liczba_kontaktow from (
select distinct customerId, tytuł, year([FAKTURA DATA WYSTAWIENIA])as rok,5 as liczba from reklama
where (tytuł='adMot') and year([FAKTURA DATA WYSTAWIENIA])>=2005
union
select distinct customerId, tytuł, year([FAKTURA DATA WYSTAWIENIA]) as rok,3 as liczba from reklama
where (tytuł='GS') and year([FAKTURA DATA WYSTAWIENIA])>=2005
union
select distinct customerId, tytuł, year([FAKTURA DATA WYSTAWIENIA]) as rok,1 as liczba from reklama
where (tytuł='AMT') and year([FAKTURA DATA WYSTAWIENIA])>=2005
) t1 left join
(select count(*) as liczba_kontaktow, customerId as custId, year(data) as rok1 from dbo.KONTAKTY
where year(data) >=2005 group by customerId, year(data) ) t2
on t1.customerId = t2.custId and t1.rok = t2.rok1
group by rok, customerId, liczba_kontaktow
) t3
group by rok, liczba order by rok desc, liczbatrued1System.Int32c1System.Int32c2System.Int32c3System.Int32BAZA_REKLAMselect d1,c1,c2,c3 from (
(select count( distinct customerID) as c1, year(data) as d1 from dbo.KONTAKTY where opis like '%G*%' group by year(data)) t1
left join
(select count( distinct customerID) as c2, year(data) as d2 from dbo.KONTAKTY where opis like '%T*%' group by year(data)) t2
on t1.d1=t2.d2
left join
(select count( distinct customerID) as c3, year(data) as d3 from dbo.KONTAKTY group by year(data)) t3
on t2.d2=t3.d3 )
order by d1 desctrue16.5cm1cmInside0true2Kontakty3trueRealCylinder011.25cmPlainInside0truetruetrueColumn16.25cm=Fields!d1.ValuePastel=Fields!c1.Value=Fields!c1.Valuetrue6pt=Fields!c2.Value=Fields!c2.Valuetrue6pt=Fields!c3.Value=Fields!c3.Valuetrue6pt