[步骤]
declare @CustomerID int= 1 ,@VideoGenerateState int= 2 ,@IsUpLoad bit= 0 ,@IsDelete bit= 0 ,@StartTime datetime= '2022/5/1 0:00:00' ,@EndTime datetime= '2024/3/27 23:59:59'SELECT distinct a.Id, a.DataSource AS VideoType, a.OrderSourceId, c.OrderSourceName, a.OrderSourceCountry, a.Asin as ASIN, a.SKU, CASE WHEN d.id IS NULL THEN 1 --没有策略的默认是腾讯
ELSE d.ServiceProvider END AS ServiceProvider, a.VideoTemplateId, a.VideoTemplateName, f.ID AS BrandId, e.BrandName, a.VideoUrl, a.OrderSourceSKUID FROM dbo.RB_ProductVideo_List a with(NOLOCK) LEFT JOIN dbo.RB_OrderSource c(NOLOCK) ON a.OrderSourceId = c.ID AND a.CustomerID = c.CustomerID LEFT JOIN dbo.RB_ProductVideo_Strategy_History d(NOLOCK) ON a.CustomerID = d.CustomerID AND a.BatchId = d.BatchId LEFT JOIN RB_Amazon_Product_Base_Brand e(NOLOCK) ON a.OrderSourceId=e.OrderSourceId AND a.OrderSourceSKU=e.OrderSourceSKU AND a.CustomerID = e.CustomerId LEFT JOIN dbo.RB_Product_Brand f(NOLOCK) ON e.CustomerId=f.CustomerID AND e.BrandName=f.BrandName AND f.IsActive=1 WHERE a.CustomerID =@CustomerID AND a.VideoGenerateState = @VideoGenerateState AND a.IsUpLoad = @IsUpLoad AND a.IsDelete = @IsDelete AND a.VideoCheckTime >=@StartTime AND a.VideoCheckTime <=@EndTime and a.SKU in('16543854','16513508','15882797','16857008','16848393','16513477','16023119','15920974','11704105','16845593','14114052','13303610','15461343','16509209','16114087','15911370','15442922','16844964','11701267','15426448','15889764','13301992','16841857','14094559','15845990','15393252','16838722','16063457','16490646','16035793','14087394','16023359')
[结果]
[期望]
改善优化查询 提升性能
