on 10-09-2008 4:44 AM
Hello all. I am attempting to write a SQL query that will pull the Sales Order #, Any items in that Sales Order and their respective Serial #'s (If any). The problem with my query is that I am pulling Serial #'s that don't even exist for that particular item. I created a drill down to the Item Master Data for each item, and if I click on my drill down, the serial & batch # option is managed by: "None". I do not want to pull any serial #'s unless this particular item is "Managed by Serial #". I don't know what I'm doing wrong.
SELECT Distinct RDR1.DocEntry, SRI1.ItemCode AS Item, SRI1.ItemName AS Description, SRI1.BaseType, OSRI.IntrSerial AS Serial, ORDR.DocNum,
SRI1_1.ItemCode, OSRI.Quantity
FROM OSRI INNER JOIN
SRI1 ON OSRI.ItemCode = SRI1.ItemCode AND OSRI.SysSerial = SRI1.SysSerial INNER JOIN
ORDR ON SRI1.BaseEntry = ORDR.DocEntry INNER JOIN
SRI1 AS SRI1_1 ON OSRI.ItemCode = SRI1_1.ItemCode INNER JOIN
ODLN ON SRI1_1.BaseEntry = ODLN.DocEntry INNER JOIN
RDR1 ON ORDR.DocEntry = RDR1.DocEntry
If someone could see what I'm doing wrong, it would be greatly appreciated. Thanks in advance.
I figured this out, but here it is for future reference to someone who runs into the same problem:
CASE WHEN OITM.ManSerNum = 'Y' THEN OSRI.IntrSerial ELSE 'None' END AS 'Serial #'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.