© 2026 Hedgehog Software, LLC
select inv_mast.item_id, sum(qty_on_hand) qty_on_hand, max(invoice_date) latest_invoice_date from inv_mast join inv_loc on inv_loc.inv_mast_uid = inv_mast.inv_mast_uid full join p21_sales_history_report_view on inv_mast.inv_mast_uid = p21_sales_history_report_view.inv_mast_uid where qty_on_hand > 0 and location_id <> 40 and latest_invoice_date <= DATEADD(YEAR,-2,getdate()) group by inv_mast.item_id
latest_invoice_date
Invalid column name 'latest_invoice_date'.