select tpf.* from tbl_MFR_TPF_Detail tpf with (nolock) inner join tbl_CDR_Distributors cdr with (nolock) on cdr.cdr_recordId = tpf.tpartnerId and cdr.ownerId = tpf.mfr_id and cdr.fsl_tablecode= 'MFR' where tpf.productLevel = 'SKU' and tpf.tpartnerType = 'CDR' and tpf.forecast_status = 'A' and cdr.ownerId = and cdr.fsl_tablecode = order by forecast_year desc, forecast_month desc update tbl_MFR_TPF_Detail set forecast_month = , forecast_year = where mfr_id = and tpartnerId = and tpartnerType = and productItemCode = and productLevel = and forecast_year = and forecast_month = and forecast_status = ---> select tpf.* from tbl_MFR_TPF_Detail tpf with (nolock) inner join tbl_TER_Territories ter with (nolock) on ter.territoryId = tpf.tpartnerId and ter.ownerId = tpf.mfr_id and ter.fsl_tablecode = 'MFR' where tpf.productLevel = 'UOM' and tpf.tpartnerType = 'TER' and tpf.forecast_status = 'Q' and ter.ownerId = and ter.fsl_tablecode = order by forecast_year desc, forecast_month desc update tbl_MFR_TPF_Detail set forecast_month = , forecast_year = where mfr_id = and tpartnerId = and tpartnerType = and productItemCode = and productLevel = and forecast_year = and forecast_month = and forecast_status =