I know I am messing up somehow, but not 100 % sure where....
I have this SQL statement, where I want to grab all records with criteria, but if a record doesn't exist in the JobOperations table I still want a "Null" record pulled indicating there are no operations corresponding to the JobAssemblies record. I tried using the CASE WHEN syntax, although I get no errors, I also don't get the "null" records I was hoping for.
Can someone guide me as to how to rearrange my SQL?
Note fields beginning in jmp belong to Jobs table, jma belong to JobAssemblies table and jmo belong to JobOperations table.
Select jmaJobID,jmaParentAssemblyID,jmaPartID,jmaPartShortDescription, jmoJobOperationID,(CASE WHEN jmoWorkCenterID is Null Then ' ' else jmoWorkCenterID END) as WC
FROM Jobs left outer join JobAssemblies on jmaJobID = jmpJobID Left Outer Join JobOperations On jmaJobID= jmoJobID And jmaJobAssemblyID = jmoJobAssemblyID
Where jmpClosed = 0 and jmpProductionComplete = 0 and jmaIssuedComplete = 0 and jmoProductionComplete = 0 and jmoWorkCenterID <> 'ASSY'
Thank you.
I have this SQL statement, where I want to grab all records with criteria, but if a record doesn't exist in the JobOperations table I still want a "Null" record pulled indicating there are no operations corresponding to the JobAssemblies record. I tried using the CASE WHEN syntax, although I get no errors, I also don't get the "null" records I was hoping for.
Can someone guide me as to how to rearrange my SQL?
Note fields beginning in jmp belong to Jobs table, jma belong to JobAssemblies table and jmo belong to JobOperations table.
Select jmaJobID,jmaParentAssemblyID,jmaPartID,jmaPartShortDescription, jmoJobOperationID,(CASE WHEN jmoWorkCenterID is Null Then ' ' else jmoWorkCenterID END) as WC
FROM Jobs left outer join JobAssemblies on jmaJobID = jmpJobID Left Outer Join JobOperations On jmaJobID= jmoJobID And jmaJobAssemblyID = jmoJobAssemblyID
Where jmpClosed = 0 and jmpProductionComplete = 0 and jmaIssuedComplete = 0 and jmoProductionComplete = 0 and jmoWorkCenterID <> 'ASSY'
Thank you.