我的问题是,目前有以下代码:
SELECT *
FROM
(
SELECT p.product,
p.description,
p.warehouse,
CASE
WHEN RIGHT(RTRIM(p.product),2) = '+P' THEN (SELECT physical_qty - allocated_qty FROM scheme.stockm p2 WHERE p2.warehouse = p.warehouse AND p2.product = REPLACE(p.product, '+P', ''))
WHEN RIGHT(RTRIM(p.product),2) = '+P1' THEN (SELECT physical_qty - allocated_qty FROM scheme.stockm p2 WHERE p2.warehouse = p.warehouse AND p2.product = REPLACE(p.product, '+P1', ''))
ELSE physical_qty - allocated_qty
END AS 'Stock',
CASE
WHEN warehouse = 'X1' THEN trade.price * 0.85
ELSE trade.price * 0.8
END AS 'Price'
FROM scheme.stockm p INNER JOIN
scheme.oplistm AS trade WITH(NOLOCK) ON p.product = trade.product_code AND trade.price_list = 'MT'
WHERE (warehouse = 'X1'
OR warehouse = 'X2')
AND analysis_b <> '0421'
AND analysis_b <> '0531'
AND analysis_b <> '0409'
) AS t
WHERE t.Stock > 0
AND RTRIM(product) + '+P' NOT IN
(SELECT product
FROM scheme.stockm
WHERE warehouse = 'X1'
OR warehouse = 'X2')
AND RTRIM(product) + '+P1' NOT IN
(SELECT product
FROM scheme.stockm
WHERE warehouse = 'X1'
OR warehouse = 'X2')
AND product NOT LIKE 'BAG%'
AND product NOT LIKE 'MDS%'
AND UPPER(description) NOT LIKE '%STAND%'
此代码目前列出了所有产品的价目表,但标题中包含+ p的产品系列除外?我正在询问当前代码需要做什么才能将产品范围包含在+ p中?因为这需要包括在内。
非常感谢任何帮助。
亲切的问候 Dean Gent