我有这个多选择视图(由前工作人员撰写),我正尝试将其放入SSRS并获取基于Items.Class_02的参数。
我创建了第二个数据集(来自Items的SELECT DISTINCT Class_02,在选择参数之前一切似乎都还不错。它为我提供了视图中的所有内容,而不仅仅是所选参数。
SELECT TOP (100) PERCENT stk.SearchCode, stk.warehouse, stk.ItemCode, Items.Class_02, stk.Description, stk.Assortment, stk.ItemGroup, stk.ItemStatus, stk.ItemUnit, ROUND(stk.Stock / stk.SalesPkg, 2) AS Stock, stk.AmtActualStock,
stk.Supplier, dbo.cicmpy.cmp_name, dbo.ItemAccounts.ItemCodeAccount
FROM dbo.Items INNER JOIN
(SELECT v.magcode AS warehouse, MAX(i.ItemCode) AS ItemCode, MAX(i.Description_0) AS Description, i.SearchCode, MAX(ia.Assortment) AS Assortment, MAX(ia.Description_0) AS ItemGroup,
MAX(CASE WHEN i.condition = 'A' THEN 'Active' WHEN i.condition = 'B' THEN 'Blocked' WHEN i.condition = 'D' THEN 'Discontinued' WHEN i.condition = 'E' THEN 'Inactive' WHEN i.condition = 'F' THEN
'Future' END) AS ItemStatus, ISNULL(MAX(a.PurchasePackage), '-') AS ItemUnit, MAX(i.SalesPackagePrice) AS SalesPackagePrice, MAX(v.bestniv) AS Minimum, MAX(v.maxvrd) AS Maximum,
MAX(i.lev_crdnr) AS Supplier, MAX(a.DeliveryTimeInDays) AS DeliveryTime, MAX(ISNULL(a.SlsPkgsPerPurPkg, 1)) AS SalesPkg, ISNULL(Actual.Quantity, 0) AS Stock, ISNULL(Actual.AmtActualStock,
0) AS AmtActualStock, ISNULL(MAX(i.CostPriceStandard), 0) AS CostPrice, ISNULL(Actual.FreeQuantity, 0) AS FreeStock
FROM dbo.Items AS i INNER JOIN
dbo.voorrd AS v ON i.ItemCode = v.artcode LEFT OUTER JOIN
dbo.ItemAccounts AS a ON i.ItemCode = a.ItemCode AND i.lev_crdnr = a.crdnr AND i.ItemCode IS NOT NULL AND a.ItemCode IS NOT NULL AND i.lev_crdnr IS NOT NULL AND a.crdnr IS NOT NULL
INNER JOIN
dbo.ItemAssortment AS ia ON ia.Assortment = i.Assortment LEFT OUTER JOIN
(SELECT artcode, Warehouse, Quantity, AmtActualStock, TotalCnt,
CASE WHEN GX.FreeQuantity > GX.CurrentQuantity THEN (CASE WHEN GX.CurrentQuantity < 0 THEN 0 ELSE GX.CurrentQuantity END)
ELSE (CASE WHEN GX.FreeQuantity < 0 THEN 0 ELSE GX.FreeQuantity END) END AS FreeQuantity
FROM (SELECT sb.ItemCode AS artcode, SUM(sb.Quantity) AS Quantity, ROUND(SUM(sb.StockAmount), 2) AS AmtActualStock,
SUM(CASE WHEN sb.Date <= { d '2010-02-13' } THEN sb.Quantity END) AS CurrentQuantity, SUM(CASE WHEN sb.Date <= { d '2010-02-13' } THEN sb.FreeStock END)
AS FreeQuantity, sb.Warehouse, SUM(sb.GbkmutCount) AS TotalCnt
FROM dbo.StockBalances AS sb WITH (NOLOCK) INNER JOIN
dbo.Items AS Items_1 ON sb.ItemCode = Items_1.ItemCode INNER JOIN
dbo.ItemAssortment ON Items_1.Assortment = dbo.ItemAssortment.Assortment
GROUP BY sb.ItemCode, sb.Warehouse
HAVING (SUM(sb.GbkmutCount) >-1)) AS GX) AS Actual ON Actual.artcode = i.ItemCode AND Actual.Warehouse = v.magcode AND Actual.artcode IS NOT NULL AND
i.ItemCode IS NOT NULL AND Actual.Warehouse IS NOT NULL AND v.magcode IS NOT NULL
WHERE (ROUND(Actual.Quantity, 2) <> 0) AND (i.Type IN ('S', 'B')) AND (i.ItemCode BETWEEN '_FG001' AND 'XS45000') AND (i.Condition IN ('A')) AND (i.IsSalesItem <> 0) AND (i.Type IN ('S', 'B')) AND
(1 = 1) OR
(ROUND(Actual.Quantity, 2) <> 0) AND (i.Type IN ('S', 'B')) AND (i.ItemCode BETWEEN '_FG001' AND 'XS45000') AND (i.Condition IN ('A')) AND (i.IsSalesItem <> 0) AND (i.Type IN ('S', 'B')) AND
(1 = 1) OR
(ROUND(Actual.Quantity, 2) <> 0) AND (i.Type IN ('S', 'B')) AND (i.ItemCode BETWEEN '_FG001' AND 'XS45000') AND (i.Condition IN ('A')) AND (i.IsSalesItem <> 0) AND (i.Type IN ('S', 'B')) AND (1 = 1)
AND (Actual.Quantity <> 0)
GROUP BY v.magcode, i.ItemCode, i.SearchCode, Actual.Quantity, Actual.AmtActualStock, Actual.FreeQuantity) AS stk ON dbo.Items.ItemCode = stk.ItemCode INNER JOIN
dbo.grtbk ON dbo.Items.GLAccountDistribution = dbo.grtbk.reknr LEFT OUTER JOIN
dbo.ItemAccounts ON stk.Supplier = dbo.ItemAccounts.crdnr AND stk.ItemCode = dbo.ItemAccounts.ItemCode LEFT OUTER JOIN
dbo.cicmpy ON stk.Supplier = dbo.cicmpy.crdnr
ORDER BY stk.ItemCode
当我从下拉菜单中选择GREEN时,我希望在Class_02中仅看到具有GREEN的行,但我看到的一切都如此。