Dear colleagues, I grabbed a query that I thought was simple but it's complicated!
I have a database where I have all my NF per product incoming goods, I need to find the value of the product in the last entry of the year.
I arrived easy on the date of the note of each product, I grouped by product and gave a max
on the date, so far so good, but to bring the value that is the problem, if I add the value in group by
it shows the products several times!
SELECT produto, MAX(data)
FROM notas
WHERE data < '2016-01-01'
GROUP BY produto <--- precisava trazer o valor da ultima entrada nessa query
Thank you in advance!