select interactionDetailId, saleSubjectType, saleSubjectId, saleQty, saleDurationUnit from tbl_CRM_InteractionSaleDetails isd where saleQty > 0 and saleDurationUnit is null and annualCaseAmt is null and ownerId = 14 and saleSubjectType = 'SKU' and disposition = '?' and exists ( select * from tbl_CRM_interactions i where ownerId = 14 and disposition = '?' and i.interactionId = isd.interactionId ) order by interactionDetailId desc select isd.ownerId, isd.ownerType, isd.interactionDetailId, isd.saleSubjectType, isd.saleSubjectId, isd.saleQty, isd.saleDurationUnit from tbl_CRM_interactionSaleDetails isd inner join tbl_PRD_SKus s on s.skuId = isd.saleSubjectId and s.mfrId = inner join tbl_CRM_Interactions i on i.interactionId = isd.interactionId where isd.saleSubjectType = 'SKU' -- and isd.saleDurationUnit in ( 'WK','MO','YR' ) and isd.saleQty > 0 and nullif( isd.annualCaseAmt, 0 ) is null and isd.ownerId = and isd.ownerType = and i.disposition = '?' and isd.disposition <> 'NS' update tbl_CRM_InteractionSaleDetails set annualCaseAmt = , annualWeightAmt = , annualDollarAmt = , saleDurationUnit = , fixed = 'Y' where interactionDetailId = and ownerId = and ownerType = select isd.ownerId, isd.ownerType, isd.interactionDetailId, isd.saleSubjectType, isd.saleSubjectId, isd.saleQty, isd.saleDurationUnit from tbl_CRM_interactionSaleDetails isd inner join tbl_PRD_SKus s on s.skuId = isd.saleSubjectId and s.mfrId = inner join tbl_CRM_Interactions i on i.interactionId = isd.interactionId where isd.saleSubjectType = 'SKU' -- and isd.saleDurationUnit in ( 'WK','MO','YR' ) and isd.saleQty > 0 and nullif( isd.annualCaseAmt, 0 ) is null and isd.ownerId = and isd.ownerType = and i.disposition = '?' and isd.disposition <> 'NS'