#Parameter1:Datum von:datetime:firstofcurrentyear
#Parameter2:Datum bis:datetime:currentdate
#Parameter3:Behandler:DataTable:select name+' '+vorname from privat where behandler=1 AND aktiv=1 order by nrprivat
-SQL-
SELECT        Nrfaktura, Nrdebitor, Nrpatient, Datum, Total, dbo.faktura.Status, dbo.get_name(Nrpatient) AS Patient, case when nrdebitor<>nrpatient then dbo.get_name(Nrdebitor) else '' end AS Debitor, dbo.privat.name+' '+dbo.privat.vorname as behandler
FROM            dbo.Faktura  JOIN
                         dbo.PRIVAT ON dbo.Faktura.Nrbehandler = dbo.PRIVAT.NRPRIVAT
where  datum>='#Parameter1 00:00:00' and datum <='#Parameter2 23:59:59' and (''='#Parameter3' or '#Parameter3'= dbo.privat.name+' '+dbo.privat.vorname)  