Greetings,
This should be so simple. I was asked to knock out Obsolete Parts from several queries. The complicated part is that there are two things that can indicate an Obsolete Part... this application can declare the Part Obsolete, or JDE (Production ERP) may.
So for Fandango, a special value [p].[stocktypeid] = 1 is what indicates an Obsolete Part. For JDE, [jim].[stktyp] = 'O' indicates Obsolete Part.
Merely adding the Fandango restriction eliminates the query's entire result set!!! :banghead:
The test parts I am dealing with have a NULL [p].[stocktypeid] as one has not been defined yet in my test data. Which NULL <> 1, so that should not have knocked the records out of the result set.
Requesting another set of eyes. Perhaps you can see something that I am overlooking.
And the result set with the "AND ([p].[stocktypeid] <> 1) " commented, in addition to the JDE LOC being commented.
This should be so simple. I was asked to knock out Obsolete Parts from several queries. The complicated part is that there are two things that can indicate an Obsolete Part... this application can declare the Part Obsolete, or JDE (Production ERP) may.
So for Fandango, a special value [p].[stocktypeid] = 1 is what indicates an Obsolete Part. For JDE, [jim].[stktyp] = 'O' indicates Obsolete Part.
Merely adding the Fandango restriction eliminates the query's entire result set!!! :banghead:
The test parts I am dealing with have a NULL [p].[stocktypeid] as one has not been defined yet in my test data. Which NULL <> 1, so that should not have knocked the records out of the result set.
Requesting another set of eyes. Perhaps you can see something that I am overlooking.
Code:
-- Needed for debugging
DECLARE @projid smallint;
SET @projid = 1;
SELECT DISTINCT [p].[id],
[p].[stocktypeid],
[p].[buyercodetypeid],
[pbc].[title] AS [buyercodetypetitle],
[p].[cmdtycodetypeid],
[pcc].[title] AS [cmdtycodetypetitle],
[p].[partnumber],
[p].[title] AS [parttitle],
[p].[rev],
dbo.frevconv_ConvN2A([p].[rev]) AS [revdisp]
FROM [dbo].[projects] AS [proj]
INNER JOIN [dbo].[products] AS [prod] ON [proj].[id] = [prod].[projectid]
INNER JOIN [dbo].[productpartlink] AS [ppl] ON [prod].[id] = [ppl].[productid]
INNER JOIN [dbo].[parts] AS [p] ON [ppl].[partid] = [p].[id]
LEFT JOIN [dbo].[partsbuyercodetype] AS [pbc] ON [p].[buyercodetypeid] = [pbc].[id]
LEFT JOIN [dbo].[partscmdtycodetype] AS [pcc] ON [p].[cmdtycodetypeid] = [pcc].[id]
LEFT JOIN [dbo].[jdeitemmaster] AS [jim] ON [p].[partnumber] = [jim].[partnumber]
LEFT JOIN [dbo].[quotes] AS [q] ON [p].[quoteid] = [q].[id]
WHERE [proj].[id] = @projid -- All Parts associated with this Project
AND (([p].[quoteid] IS NULL) -- No selected quote
AND ([jim].[partnumber] IS NULL)) -- And not a production Part number
[COLOR=Red][B]AND ([p].[stocktypeid] <> 1) -- And not Fandango Obsolete[/B]
-- OR ([jim].[stktyp] <> 'O')) -- Or JDE Obsolete[/COLOR]
ORDER BY [p].[id];
Code:
id stocktypeid buyercodetypeid buyercodetypetitle cmdtycodetypeid cmdtycodetypetitle partnumber parttitle rev revdisp
16 NULL NULL NULL NULL NULL 12435687 Testing Router Complete Flag 103 D
18 NULL NULL NULL NULL NULL 6500001020 Testing BOM Loaded Flg 100 A