1
Dear colleagues I took a query that I thought was simple but it’s complicated!
I have a database where I have all my NF per commodity input product, I need to find the product value 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 date, so far so good, but to bring the value that is being 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
Thanks in advance!
tries to place the
trunc
at date: Where trunc(date) < to_date('2016-01-01', 'yyyy-dd-mm')– Marllon Nasser