Hi - I'm a relatively novice sql user. I'm trying to write a query to check for me when a client has reported sales for the past month, but their last report was not on the last day of the month. Here's what I have, but I get an error stating:
Msg 206, Level 16, State 2, Line 4
Operand type clash: date is incompatible with int
DECLARE @date DATETIME = GETDATE()
SELECT [ClientID]
,[ClientName]
,CASE WHEN MAX(DAY([PurchaseDate])) = EOMONTH(@date,-1)
then 'COMPLETE'
else MAX([PurchaseDate])
end as LastReportedSale
FROM [Data].[Reporting].[Sales]
where SaleMonth = (MONTH(GetDate())-1)
and SaleYear = 2018
Group by ClientID, ClientName
Order by LastReportedSale Asc
Greatly appreciate any input and guidance.