--zad 9
create function fnDohvatRacunaTmTbl (@D1 datetime, @D2 datime)
returns @tbl Table
(
DatumIzdavanja datetime,
BrojRacuna nvarchar(25),
Ime nvarchar(50),
Prezime Nvarchar(50)
)
begin
	insert into @tbl (DatumIzdavanja, BrojRacunal, Ime, Prezime)
	select r.DatumIzdavanja, r.BrojRacuna, k.Ime, k.Prezime from Racun as r
inner join Kupac as k ON k.IDKupac = r.KupacID	
	Where r.DatumIzdavanja between @D1 AND @D2
	return
end

select * from dbo.fnDohvatRacunaTmTbl('20040601','20040603')

drop function dbo.fnDohvatRacunaTmTbl


