I need to value the company inventory in which I work, for this I will get the last value of the items, I was using Max, but I realized that if I did this he would return me the highest price and not the last one registered in the table so I changed the max for the date column, but it brings me several lines of results, and I need only the last but still with the code field and value of the items, and then play in a spreadsheet, I will post The Code here below
select irec.pro_in_codigo Codigo, irec.rci_re_vlunitario Valor_unitario, max(irec.rcb_dt_documento) Data
from mgadm.est_itensreceb irec
where irec.pro_in_codigo = 701
group by irec.pro_in_codigo, irec.rci_re_vlunitario
thanks.