I am not accustomed to using SQL for View Creation, It's forcing me to use HAVING and GROUP BY, in a standard SQL statement i would use WHERE but apparently that's not allowed. I want to SELECT DISTINCT on dbo.[ShowTex Belgie NV$Item].No_ only. But it is also combining anything i add in GROUP BY it seems. I can't use HAVING on columns unless i include them in GROUP BY. Getting this far has already taken me ages. :/ I just wanted to create a simple WHERE statement ;(
SELECT DISTINCT TOP (100) PERCENT dbo.[ShowTex Belgie NV$Item].No_, SUM(dbo.[ShowTex Belgie NV$Warehouse Entry].Quantity) AS [Quantity Sum]
FROM dbo.[ShowTex Belgie NV$Item]
LEFT OUTER JOIN dbo.[ShowTex Belgie NV$Warehouse Entry] ON dbo.[ShowTex Belgie NV$Item].No_ = dbo.[ShowTex Belgie NV$Warehouse Entry].[Item No_]
GROUP BY dbo.[ShowTex Belgie NV$Item].No_, dbo.[ShowTex Belgie NV$Warehouse Entry].[Bin Code]
HAVING (dbo.[ShowTex Belgie NV$Warehouse Entry].[Bin Code] <> 'SHIPPING') OR
(dbo.[ShowTex Belgie NV$Warehouse Entry].[Bin Code] <> 'VERZEND') OR
(dbo.[ShowTex Belgie NV$Warehouse Entry].[Bin Code] <> 'WORKSHOP')
ORDER BY dbo.[ShowTex Belgie NV$Item].No_
Using Server Studio Managment 2012 but there doesnt seem to be a hashtag for that.
As based on Gordon Linoff's Answer my SQL query became
SELECT TOP (100) PERCENT i.No_, SUM(we.Quantity) AS [Quantity Sum]
FROM dbo.[ShowTex Belgie NV$Item] AS i LEFT OUTER JOIN
dbo.[ShowTex Belgie NV$Warehouse Entry] AS we ON i.No_ = we.[Item No_]
WHERE (we.[Bin Code] NOT IN ('SHIPPING', 'VERZEND', 'WORKSHOP'))
GROUP BY i.No_
ORDER BY i.No_