Msg 102, Level 15, State 1, Line 6
Incorrect syntax near 'payment'.
Select
payvoucher.claimid,
paycheck.checknbr,
paycheck.checkamt,
(
MAX(paydate) payment.paydate FROM payment group by paydate
)
payment.payee
From
payvoucher Inner Join
paycheck
On paycheck.paymentid = payvoucher.paymentid Inner Join
payment
On payvoucher.paymentid = payment.paymentid And paycheck.paymentid =
payment.paymentid
Where
--CONVERT max(date,payment.paydate) = (select CONVERT(date, max(createdate)) from payment group by paydate) and
paycheck.checknbr not in ('NULL',' ')
Order By
paycheck.checkamt