Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

sql select giving wrong data

I have a query that is not returning what I expected - why?  why is it returning the -1
SELECT j.JobID,jde.ToolNumber,'TN' as ToolType, j.DefaultLocationIndex as 'Location' 
FROM   Job j
LEFT JOIN JobDownholeEquipment jde ON j.JobID = jde.JobID 
       WHERE j.JobInProgress= 'true' 
             OR j.JobInitiated= 'true'
             AND jde.PickedUp = 0 
             AND j.DefaultLocationIndex = 4
             [embed=file 904777]

Open in new window

Capture.PNG
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

SELECT j.JobID,jde.ToolNumber,'TN' as ToolType, j.DefaultLocationIndex as 'Location',jde.PickedUp
FROM   Job j
LEFT JOIN JobDownholeEquipment jde ON j.JobID = jde.JobID
       WHERE( j.JobInProgress= 'true'
             OR j.JobInitiated= 'true')
             AND jde.PickedUp = 0
             AND j.DefaultLocationIndex = 4