
#use int

drop view if exists v_kontrah_efaktura;
create view v_kontrah_efaktura as 
select distinct 
k.idn,k.symbol, k.nazwa, 
ifnull((select group_concat(distinct m.adres) from kontakty m where m.kontrguid=k.guid and m.typ_medium=3),'') as lista_maili
from opng n,kontrah k
where k.guid=n.kontrguid and n.datawystaw>date_sub(current_date,interval 1 month);

drop user skok_efaktura;
create user skok_efaktura identified by '@arutkafe*';
grant select on v_kontrah_efaktura to skok_efaktura;
