invalid column SQL
why is
latest_invoice_date considered an invalid column here sql error
Invalid column name 'latest_invoice_date'.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_idselect 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_idlatest_invoice_datelatest_invoice_date considered an invalid column here Invalid column name 'latest_invoice_date'.Invalid column name 'latest_invoice_date'.