I don't think so and there are two reasons for that:
- invoice no 1622 has invoice date way earlier than 2016-05-29 minus 6 months
- you are using "with (nolock)" which can give you all kinds of results (see here)
One way of solving your issue, could be:
select b.faknr as InvoiceNr
,b.fakdat as InvoiceDate
,datepart(year,b.fakdat) as YearNr
,datepart(month,b.fakdat) as MonthNr
,b.dagbknr as InvoiceType
,b.debnr as DebtorNr
,b.inv_debtor_name as DebtorName
from (select debnr
,dateadd(month,-6,max(fakdat)) as fakdat
from dbo.frhkrg
group by debnr
) as a
inner join dbo.frhkrg as b
on b.debnr=a.debnr
and b.fakdat>=a.fakdat
;