Hi All
I am very new to SQL and this is probably a very simple answer but I cannot fathom how to resolve the issue.
We pass an work order ref into a table, and this is held by the field 'SELDTL_STR_FLD3'.
I have an order start date and a priority, and all I want to do is return a 'due date' by taking the start date and adding the priority to that date:
select DATEADD(day,priority.PRIORITY_DAYS,wo.WORKORDER_START_DATE) as DueDate
from PM_PRIORITY as priority, PM_WORKORDERS as wo, GL_SELECTION_DTL as selection
where priority.PRIORITY_CODE = wo.PRIORITY_CODE
and wo.WORKORDER_REF = selection.SELDTL_STR_FLD3
So now when I run the report (for 2 orders for example), I get the following problem:
WO1 – Due Date = 01/10/11
WO1 – Due Date = 01/11/11
WO2 – Due Date = 01/10/11
WO2 – Due Date = 01/11/11
What I actually need is:
WO1 – Due Date = 01/10/11
WO2 – Due Date = 01/11/11
Now I know it is the SQL causing the problem, as it is just running this SQL statement against each record (twice for record 1, and twice for record 2), but I am not sure how to resolve it so I only get the 2 records I need.
Look forward to your reply.
James.