MichaelaLee
Programmer
Hi Everyone,
I'm using SQL Server 2000 and have a slight problem. In my query I use a User-Defined function to get the column value as follows:
SELECT UserID, Max(Termination.DOA) AS LastAdmission,
PATIENTS.LastName + ', ' + PATIENTS.FirstName as Name,
DateAdd(m, 3, Max(Termination.DOA)) as FirstProgressDate,
dbo.nf_ComputeDate(GetDate(),Max(Termination.DOA)) AS NextDue,
DateAdd("m",-3,dbo.nf_ComputeDate(GetDate(),DateAdd(m, 3,Max(Termination.DOA)) )) AS CurrentDue
FROM Termination INNER JOIN PATIENTS ON Termination.PatientID = PATIENTS.PatientID
WHERE Termination.DOT Is Null and (NextDue >= '11/1/2004' and NextDue <= '12/30/2004')
GROUP BY Termination.PatientID, PATIENTS.LastName, PATIENTS.FirstName
As you can tell from the query above, I have three defined column names "FirstProgressDate", "NextDue" and "CurrentDue". In the where clause I need to test if the NextDue is within a date range. But if I try to run the query the way it stands I get an error:
Invalid column name 'NextDue'
Do you all know of a good way to handle this one. Thanks for any help.
Michael
I'm using SQL Server 2000 and have a slight problem. In my query I use a User-Defined function to get the column value as follows:
SELECT UserID, Max(Termination.DOA) AS LastAdmission,
PATIENTS.LastName + ', ' + PATIENTS.FirstName as Name,
DateAdd(m, 3, Max(Termination.DOA)) as FirstProgressDate,
dbo.nf_ComputeDate(GetDate(),Max(Termination.DOA)) AS NextDue,
DateAdd("m",-3,dbo.nf_ComputeDate(GetDate(),DateAdd(m, 3,Max(Termination.DOA)) )) AS CurrentDue
FROM Termination INNER JOIN PATIENTS ON Termination.PatientID = PATIENTS.PatientID
WHERE Termination.DOT Is Null and (NextDue >= '11/1/2004' and NextDue <= '12/30/2004')
GROUP BY Termination.PatientID, PATIENTS.LastName, PATIENTS.FirstName
As you can tell from the query above, I have three defined column names "FirstProgressDate", "NextDue" and "CurrentDue". In the where clause I need to test if the NextDue is within a date range. But if I try to run the query the way it stands I get an error:
Invalid column name 'NextDue'
Do you all know of a good way to handle this one. Thanks for any help.
Michael