D
davidg2356
Hello,
I have read the other postings, and I am still having problems. I have a
query that is supposed to give me the most recent (or last Completion_Date)
of either Training or Education. My first query is a union to get all the
Completion_Dates into one column, and my second query (below) is supposed to
pull up the most recent completion date per employee. (The basis for all of
this is to ultimately pull up every course between the last course taken and
the previous 2 years.)
In the first query one employee has two completion dates one being 7/30/2003
and the other 7/15/2004. For some reason, it returns 7/30/2003 as being
greater than 7/15/2004. In other word the MAX(Completion_Date) is 7/30/2003,
which is clearly wrong.
Sorry, I do not know VB, but I appreciate your time.
THANKS,
David
SELECT EMPLOYEE.Emp_ID, MAX(DATE_COURSES.DATE_FIN) AS LAST_COURSE
FROM DATE_COURSES INNER JOIN EMPLOYEE ON DATE_COURSES.Emp_ID = EMPLOYEE.Emp_ID
GROUP BY EMPLOYEE.Emp_ID
UNION SELECT EMPLOYEE.Emp_ID, NZ(MAX(DATE_COURSES.DATE_FIN),0)
FROM DATE_COURSES RIGHT JOIN EMPLOYEE ON DATE_COURSES.Emp_ID= EMPLOYEE.Emp_ID
WHERE EMPLOYEE.Emp_ID<>ALL (SELECT DATE_COURSES.Emp_ID FROM DATE_COURSES)
GROUP BY EMPLOYEE.Emp_ID;
I have read the other postings, and I am still having problems. I have a
query that is supposed to give me the most recent (or last Completion_Date)
of either Training or Education. My first query is a union to get all the
Completion_Dates into one column, and my second query (below) is supposed to
pull up the most recent completion date per employee. (The basis for all of
this is to ultimately pull up every course between the last course taken and
the previous 2 years.)
In the first query one employee has two completion dates one being 7/30/2003
and the other 7/15/2004. For some reason, it returns 7/30/2003 as being
greater than 7/15/2004. In other word the MAX(Completion_Date) is 7/30/2003,
which is clearly wrong.
Sorry, I do not know VB, but I appreciate your time.
THANKS,
David
SELECT EMPLOYEE.Emp_ID, MAX(DATE_COURSES.DATE_FIN) AS LAST_COURSE
FROM DATE_COURSES INNER JOIN EMPLOYEE ON DATE_COURSES.Emp_ID = EMPLOYEE.Emp_ID
GROUP BY EMPLOYEE.Emp_ID
UNION SELECT EMPLOYEE.Emp_ID, NZ(MAX(DATE_COURSES.DATE_FIN),0)
FROM DATE_COURSES RIGHT JOIN EMPLOYEE ON DATE_COURSES.Emp_ID= EMPLOYEE.Emp_ID
WHERE EMPLOYEE.Emp_ID<>ALL (SELECT DATE_COURSES.Emp_ID FROM DATE_COURSES)
GROUP BY EMPLOYEE.Emp_ID;