>
>Be aware this will give problems if there are two invoices on the same date. Better us TOP 1 in the correlated selects
Yes, and if you'll notice, up a few lines in my reply I mentioned that - yes, a TOP 1 is needed if there are 2 values for the same date or datetime.