I have a view I'm creating. This portion of the view works perfectly:SELECT TOP (100) PERCENT dbo.Master_Parent.Vendor, dbo.Master_Parent.Master_Parent, dbo.Master_Child.WholesaleCost, SUM(ISNULL(dbo.Master_Child.OS_3D, 0) + ISNULL(dbo.Master_Child.AZ_3D, 0) + ISNULL(dbo.Master_Child.TG_3D, 0) + ISNULL(dbo.Master_Child.SH_3D, 0) + ISNULL(dbo.Master_Child.BY_3D, 0) + ISNULL(dbo.Master_Child.QV_3D, 0) + ISNULL(dbo.Master_Child.PP_3D, 0) + ISNULL(dbo.Master_Child.EB_3D, 0) + ISNULL(dbo.Master_Child.SR_3D, 0) + ISNULL(dbo.Master_Child.MA_3D, 0) + ISNULL(dbo.Master_Child.NB_3D, 0)) AS Total3D, SUM(ISNULL(dbo.Master_Child.OS_7D, 0) + ISNULL(dbo.Master_Child.AZ_7D, 0) + ISNULL(dbo.Master_Child.TG_7D, 0) + ISNULL(dbo.Master_Child.SH_7D, 0) + ISNULL(dbo.Master_Child.BY_7D, 0) + ISNULL(dbo.Master_Child.QV_7D, 0) + ISNULL(dbo.Master_Child.PP_7D, 0) + ISNULL(dbo.Master_Child.EB_7D, 0) + ISNULL(dbo.Master_Child.SR_7D, 0) + ISNULL(dbo.Master_Child.MA_7D, 0) + ISNULL(dbo.Master_Child.NB_7D, 0)) AS Total7D, SUM(ISNULL(dbo.Master_Child.OS_30D, 0) + ISNULL(dbo.Master_Child.AZ_30D, 0) + ISNULL(dbo.Master_Child.TG_30D, 0) + ISNULL(dbo.Master_Child.SH_30D, 0) + ISNULL(dbo.Master_Child.BY_30D, 0) + ISNULL(dbo.Master_Child.QV_30D, 0) + ISNULL(dbo.Master_Child.PP_30D, 0) + ISNULL(dbo.Master_Child.EB_30D, 0) + ISNULL(dbo.Master_Child.SR_30D, 0) + ISNULL(dbo.Master_Child.MA_30D, 0) + ISNULL(dbo.Master_Child.NB_30D, 0)) AS Total30D, SUM(ISNULL(dbo.Master_Child.OS_60D, 0) + ISNULL(dbo.Master_Child.AZ_60D, 0) + ISNULL(dbo.Master_Child.TG_60D, 0) + ISNULL(dbo.Master_Child.SH_60D, 0) + ISNULL(dbo.Master_Child.BY_60D, 0) + ISNULL(dbo.Master_Child.QV_60D, 0) + ISNULL(dbo.Master_Child.PP_60D, 0) + ISNULL(dbo.Master_Child.EB_60D, 0) + ISNULL(dbo.Master_Child.SR_60D, 0) + ISNULL(dbo.Master_Child.MA_60D, 0) + ISNULL(dbo.Master_Child.NB_60D, 0)) AS Total60D, (((SUM(ISNULL(dbo.Master_Child.OS_3D, 0) + ISNULL(dbo.Master_Child.AZ_3D, 0) + ISNULL(dbo.Master_Child.TG_3D, 0) + ISNULL(dbo.Master_Child.SH_3D, 0) + ISNULL(dbo.Master_Child.BY_3D, 0) + ISNULL(dbo.Master_Child.QV_3D, 0) + ISNULL(dbo.Master_Child.PP_3D, 0) + ISNULL(dbo.Master_Child.EB_3D, 0) + ISNULL(dbo.Master_Child.SR_3D, 0) + ISNULL(dbo.Master_Child.MA_3D, 0) + ISNULL(dbo.Master_Child.NB_3D, 0)) / 3 + SUM(ISNULL(dbo.Master_Child.OS_7D, 0) + ISNULL(dbo.Master_Child.AZ_7D, 0) + ISNULL(dbo.Master_Child.TG_7D, 0) + ISNULL(dbo.Master_Child.SH_7D, 0) + ISNULL(dbo.Master_Child.BY_7D, 0) + ISNULL(dbo.Master_Child.QV_7D, 0) + ISNULL(dbo.Master_Child.PP_7D, 0) + ISNULL(dbo.Master_Child.EB_7D, 0) + ISNULL(dbo.Master_Child.SR_7D, 0) + ISNULL(dbo.Master_Child.MA_7D, 0) + ISNULL(dbo.Master_Child.NB_7D, 0)) / 7) + SUM(ISNULL(dbo.Master_Child.OS_30D, 0) + ISNULL(dbo.Master_Child.AZ_30D, 0) + ISNULL(dbo.Master_Child.TG_30D, 0) + ISNULL(dbo.Master_Child.SH_30D, 0) + ISNULL(dbo.Master_Child.BY_30D, 0) + ISNULL(dbo.Master_Child.QV_30D, 0) + ISNULL(dbo.Master_Child.PP_30D, 0) + ISNULL(dbo.Master_Child.EB_30D, 0) + ISNULL(dbo.Master_Child.SR_30D, 0) + ISNULL(dbo.Master_Child.MA_30D, 0) + ISNULL(dbo.Master_Child.NB_30D, 0)) / 30) + SUM(ISNULL(dbo.Master_Child.OS_60D, 0) + ISNULL(dbo.Master_Child.AZ_60D, 0) + ISNULL(dbo.Master_Child.TG_60D, 0) + ISNULL(dbo.Master_Child.SH_60D, 0) + ISNULL(dbo.Master_Child.BY_60D, 0) + ISNULL(dbo.Master_Child.QV_60D, 0) + ISNULL(dbo.Master_Child.PP_60D, 0) + ISNULL(dbo.Master_Child.EB_60D, 0) + ISNULL(dbo.Master_Child.SR_60D, 0) + ISNULL(dbo.Master_Child.MA_60D, 0) + ISNULL(dbo.Master_Child.NB_60D, 0)) / 60) / 4 AS [Average Daily Sellthrough], SUM(dbo.Master_Child.PoolInventory) AS SumOfpoolinventory, dbo.Master_Child.WholesaleCost * dbo.Master_Child.PoolInventory AS ExposureFROM dbo.Master_Child INNER JOIN dbo.Master_Parent ON dbo.Master_Child.Master_Parent = dbo.Master_Parent.Master_ParentGROUP BY dbo.Master_Parent.Vendor, dbo.Master_Parent.Master_Parent, dbo.Master_Child.WholesaleCost, dbo.Master_Child.WholesaleCost * dbo.Master_Child.PoolInventoryHAVING (SUM(dbo.Master_Child.PoolInventory) > 0)ORDER BY [Average Daily Sellthrough], Exposure DESC
However, I need the results of this data set to interface with another table called StaleInventoryTracking. That table has Master_Parent just like the coding in the view. I was thinking a statement like this:WHERE (NOT EXISTS (SELECT Master_ParentFROM dbo.StaleInventoryTracking WHERE (dbo.Master_Parent.Master_Parent = Master_Parent) GROUP BY dbo.StaleInventoryReport.Date HAVING (Date < GETDATE()-14)))
The goal is to have the results from the main portion of the view narrowed by whether there is a matching sku on the staleinventorytracking table that was placed on that table within the last 14 days.Any ideas?