LloydDobler
Technical User
Hello all, I have 2 tables I'm looking to query. Here's what I have so far:
Which returns:
Machine StDate freq PMdate NEXTPMDATE
ABCD 01/01/07 30 NULL NULL
1234 02/02/07 30 02/15/07 03/15/07
xyz 02/02/07 30 NULL NULL
9999 01/01/07 30 01/29/07 02/28/07
My problem is I want the 'startdate' to be the "nextPMDATE" if the field e.pmdate is null, and I have no idea how to go about this.
"I don't want to sell anything, buy anything or process anything as a career. I don't want to sell anything bought or processed... or buy anything sold or processed... or process anything sold, bought or processed... or repair anything sold, bought or processed. You know, as a career, I don't want to do that."
Code:
SELECT S.Machinenumber, S.StartingDate, S.frequency, E.PMdate, CONVERT(varchar(10), DATEADD(dd, S.frequency, E.PMdate), 101) AS NEXTPMDATE,
S.task
FROM dbo.tbl_PM_Schedule S LEFT OUTER JOIN
dbo.tbl_PM_Entries E ON S.Machinenumber = E.machinenumber
WHERE (S.activetask = 'Y') AND (S.tasktype = 'PM') AND (S.Division = 1)
Which returns:
Machine StDate freq PMdate NEXTPMDATE
ABCD 01/01/07 30 NULL NULL
1234 02/02/07 30 02/15/07 03/15/07
xyz 02/02/07 30 NULL NULL
9999 01/01/07 30 01/29/07 02/28/07
My problem is I want the 'startdate' to be the "nextPMDATE" if the field e.pmdate is null, and I have no idea how to go about this.
"I don't want to sell anything, buy anything or process anything as a career. I don't want to sell anything bought or processed... or buy anything sold or processed... or process anything sold, bought or processed... or repair anything sold, bought or processed. You know, as a career, I don't want to do that."