After having a week off still having issues with this report so thought I'd post up a reply to clarify the issue and try and get a hand with it.The original sql is this:SELECT PART.ID, PART.DESCRIPTION, PART.FABRICATED, PART.PURCHASED, PART.BUYER_USER_ID, REQUIREMENT.ISSUED_QTY, REQUIREMENT.CALC_QTYFROM PART INNER JOIN REQUIREMENT ON PART.ID = REQUIREMENT.PART_ID INNER JOIN WORK_ORDER ON REQUIREMENT.WORKORDER_TYPE = WORK_ORDER.TYPE AND REQUIREMENT.WORKORDER_BASE_ID = WORK_ORDER.BASE_ID AND REQUIREMENT.WORKORDER_LOT_ID = WORK_ORDER.LOT_ID AND REQUIREMENT.WORKORDER_SPLIT_ID = WORK_ORDER.SPLIT_ID AND REQUIREMENT.WORKORDER_SUB_ID = WORK_ORDER.SUB_IDWHERE (WORK_ORDER.BASE_ID = @WOBase) AND (WORK_ORDER.LOT_ID = @WOLot)
Now this brings up 10 lines of data (using the parameters I'm testing with) which is correct as there's 10 parts in the Work Order. However for each fabricated part there will also be a Work Order. Therefore:SELECT PART.ID, PART.DESCRIPTION, PART.FABRICATED, PART.PURCHASED, PART.BUYER_USER_ID, REQUIREMENT.ISSUED_QTY, REQUIREMENT.CALC_QTYFROM PART INNER JOIN REQUIREMENT ON PART.ID = REQUIREMENT.PART_ID INNER JOIN WORK_ORDER ON REQUIREMENT.WORKORDER_TYPE = WORK_ORDER.TYPE AND REQUIREMENT.WORKORDER_BASE_ID = WORK_ORDER.BASE_ID AND REQUIREMENT.WORKORDER_LOT_ID = WORK_ORDER.LOT_ID AND REQUIREMENT.WORKORDER_SPLIT_ID = WORK_ORDER.SPLIT_ID AND REQUIREMENT.WORKORDER_SUB_ID = WORK_ORDER.SUB_ID LEFT OUTER JOIN WORK_ORDER AS WORK_ORDER_1 ON PART.ID = WORK_ORDER_1.PART_IDWHERE (WORK_ORDER.BASE_ID = @WOBase) AND (WORK_ORDER.LOT_ID = @WOLot)
Adding in the Work_ORDER_1 table using a Left Outer join returns 15 lines of data which once again is correct as for the fabricated parts there multiple Work Orders. However for these Work Orders I only want to return the data where WORK_ORDER_1.STATUS = 'R' but if I add this on to my WHERE clause it only returns 1 line of data. How do I add this filter to the query while still displaying the 10 oringinal lines?