I’m trying to retrieve the last invoice by location but end up getting the following error: ‘invoice_date is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.’
I’ve tried
SELECT item_id
,location_name
,SUM(invoice_date) OVER(PARTITION BY location_name) AS LastInvoiceDate
FROM items_report AS InactiveItems
GROUP BY item_id, location_name
ORDER BY item_id
But still receive the error
New contributor
Quentin Lambkin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.