hi guys,There is huge performance difference between this 2 queriesI have 2 queries one with a sub query & another one with a case statement.But the query with sub query runs much faster as compared to the case statements.First Query(With Sub query)SELECT Cn.ProgramID, Cn.ContractID, Cn.SaleDate, Cn.DealerProviderID AS DealerID, Cn.ContractTermMonthCnt, Cn.ContractIntervalMileage, PgC.ProgramFamily, PgmProd.ProductKey, PgmProd.SelectNbr, CM.ProductCommissionKey AS CM_ProductCommissionKey, CM.ProgramProductKey AS CM_ProgramProductKey, CM.ProviderProductKey AS CM_ProviderProductKey, CM.ProviderProductKey AS CM_ProviderProductKey4like, DealerFIIncentiveAmt = COALESCE ((SELECT ReferentAmt FROM DBAmt_HistoricVW AS DBc WHERE (DBc.ReferentType = 'Program' + cast(PP.ProgramID AS varchar) + '/' + cast(PgmProd.ProductTermKey AS varchar) + PP.ProviderType + 'F&IIncentive') AND (DBc.ReferentID = Cn.DealerProviderID) AND (Cn.SaleDate BETWEEN DBc.ReferentDateBGN AND DBc.ReferentDateEND)), COALESCE ((SELECT ReferentAmt FROM DBAmt_HistoricVW AS DBc WHERE (DBc.ReferentType = 'Program' + cast(PP.ProgramID AS varchar) + PP.ProviderType + 'F&IIncentive') AND (DBc.ReferentID = Cn.DealerProviderID) AND (Cn.SaleDate BETWEEN DBc.ReferentDateBGN AND DBc.ReferentDateEND)), 0)) FROM Contracts_coreTBL AS Cn INNER JOIN ContractMoneyVW AS CM ON (CM.ContractID = Cn.ContractID) INNER JOIN Programs_coreTBL AS PgC ON (PgC.ProgramID = Cn.ProgramID) AND ((PgC.ProgramFamily != 1) AND (PgC.ProgramFamily != 2) AND (PgC.ProgramFamily != 8)) INNER JOIN Programs_providersPastPresentVW AS PP ON (PP.ProviderID = Cn.DealerProviderID) AND (PP.ProgramID = Cn.ProgramID) AND (CM.ProductCommissionKey = PP.ProductCommissionKey) INNER JOIN Providers_coreTBL AS Pc ON ((PP.ProviderType = 'Dealer') OR (PP.ProviderType = 'Broker')) AND (Pc.isActive = 1) AND ((Pc.ProviderType IN ('Dealer', 'Broker'))) AND (Pc.ProviderID = PP.ProviderID) INNER JOIN Program_ProductsVW AS PgmProd ON (PgmProd.ProgramID = Cn.ProgramID) AND (((PP.ProductCommissionKey LIKE PgmProd.ProductKey) AND (CM.ProductCommissionKey LIKE PgmProd.ProductKey)) OR (PgmProd.ProductTermKey = PP.ProductCommissionKey)) order by Cn.ContractIDAnother with a case statementSELECT DISTINCT Cn.ProgramID, Cn.ContractID, Cn.SaleDate, Cn.DealerProviderID AS DealerID, Cn.ContractTermMonthCnt, Cn.ContractIntervalMileage, PgC.ProgramFamily, PgmProd.ProductKey, PgmProd.SelectNbr, CM.ProductCommissionKey AS CM_ProductCommissionKey, CM.ProgramProductKey AS CM_ProgramProductKey, CM.ProviderProductKey AS CM_ProviderProductKey, CM.ProviderProductKey AS CM_ProviderProductKey4like, CASE WHEN DBc.ReferentType='Program' + CAST(PP.ProgramID AS VARCHAR) + '/' + CAST(PgmProd.ProductTermKey AS VARCHAR) + PP.ProviderType + 'F&IIncentive' AND Cn.SaleDate BETWEEN DBc.ReferentDateBGN AND DBc.ReferentDateEND THEN ReferentAmt ELSE CASE WHEN DBc.ReferentType IS NULL THEN CASE WHEN DBc.ReferentType = 'Program' + CAST(PP.ProgramID AS VARCHAR) + PP.ProviderType + 'F&IIncentive' AND Cn.SaleDate BETWEEN DBc.ReferentDateBGN AND DBc.ReferentDateEND THEN ReferentAmt ELSE 0 END END ENDFROM Contracts_coreTBL AS Cn INNER JOIN ContractMoneyVW AS CM ON (CM.ContractID = Cn.ContractID) INNER JOIN Programs_coreTBL AS PgC ON (PgC.ProgramID = Cn.ProgramID) AND ((PgC.ProgramFamily != 1) AND (PgC.ProgramFamily != 2) AND (PgC.ProgramFamily != 8)) INNER JOIN Programs_providersPastPresentVW AS PP ON (PP.ProviderID = Cn.DealerProviderID) AND (PP.ProgramID = Cn.ProgramID) AND (CM.ProductCommissionKey = PP.ProductCommissionKey) INNER JOIN Providers_coreTBL AS Pc ON ((PP.ProviderType = 'Dealer') OR (PP.ProviderType = 'Broker')) AND (Pc.isActive = 1) AND ((Pc.ProviderType IN ('Dealer', 'Broker'))) AND (Pc.ProviderID = PP.ProviderID) INNER JOIN Program_ProductsVW AS PgmProd ON (PgmProd.ProgramID = Cn.ProgramID) AND (((PP.ProductCommissionKey LIKE PgmProd.ProductKey) AND (CM.ProductCommissionKey LIKE PgmProd.ProductKey)) OR (PgmProd.ProductTermKey = PP.ProductCommissionKey)) INNER JOIN DBAmt_HistoricVW AS DBc ON DBc.ReferentID=Cn.DealerProviderID ORDER BY Cn.SaleDateIs there any way I can improve the second query to make it run faster?