sharris_glascol
asked on
Access Query that looks at results and gives a yes no
Ok I have a table that lists Emp_id, and Course_ID, and Course_completed. Is is possible to generate a query that looks and at all of the courses for that employee and then checks date to see if they have completed all and If they have it will state MEETS REQUIREMENTS else Does not meet requirements.
ASKER
So here is my tables that I will be using. the dbo_emp_course.trainingcom pl is the table that will store the date. If no Date I need it to store a field that says Does Note Meet Requirements, but if it does Meets requirements.
SELECT dbo_EMP_Train.EmpID,
dbo_Emp_course.Course_name ,
dbo_Emp_course.TrainingCom pl
FROM
((dbo_EMP_Train INNER JOIN dbo_JobGroup ON dbo_EMP_Train.PrimaryPosit ion = dbo_JobGroup.PositionID)
INNER JOIN dbo_TrainingCourse ON dbo_JobGroup.CourseID = dbo_TrainingCourse.CourseI D)
INNER JOIN dbo_Emp_course ON dbo_TrainingCourse.CourseN ame = dbo_Emp_course.Course_name ;
SELECT dbo_EMP_Train.EmpID,
dbo_Emp_course.Course_name
dbo_Emp_course.TrainingCom
FROM
((dbo_EMP_Train INNER JOIN dbo_JobGroup ON dbo_EMP_Train.PrimaryPosit
INNER JOIN dbo_TrainingCourse ON dbo_JobGroup.CourseID = dbo_TrainingCourse.CourseI
INNER JOIN dbo_Emp_course ON dbo_TrainingCourse.CourseN
ASKER
I should add that this table could have several rows of courses some with dates and some without dates.
ASKER
example:
dbo_emp_train.empid dbo_emp_course.course_name , dbo_emp_course.trainingcom pl
2321 training a 1/1/00
2321 training b
2321 training c 1/1/00
2400 training a 2/1/00
2400 training b 2/1/00
2400 training c 2/1/00
So in this example employee 2321 would be a Does not meet requirements and employee 2400 would be Meets requirements.
dbo_emp_train.empid dbo_emp_course.course_name
2321 training a 1/1/00
2321 training b
2321 training c 1/1/00
2400 training a 2/1/00
2400 training b 2/1/00
2400 training c 2/1/00
So in this example employee 2321 would be a Does not meet requirements and employee 2400 would be Meets requirements.
It is not good practice to store calculated values. Once any one of the underlying records is updated or a new one is added, the calculated value becomes obsolete.
Did you try the query Jim posted? It is T-SQL syntax and therefore must be run as a pass-through query in Access. If you want something in Access syntax, then the following should do it.
SELECT dbo_EMP_Train.EmpID, IIf(Sum(IIf(IsDate(dbo_Emp _course.Tr ainingComp l, 1, 0)) = Count(*), "Meets Requirements", "Does Not Meet Requirements")
FROM
((dbo_EMP_Train INNER JOIN dbo_JobGroup ON dbo_EMP_Train.PrimaryPosit ion = dbo_JobGroup.PositionID)
INNER JOIN dbo_TrainingCourse ON dbo_JobGroup.CourseID = dbo_TrainingCourse.CourseI D)
INNER JOIN dbo_Emp_course ON dbo_TrainingCourse.CourseN ame = dbo_Emp_course.Course_name
Group by dbo_EMP_Train.EmpID;
You'll probably want the employee name in addition to the EmpID but you CANNOT add the course names since that would remove the aggregation.
Did you try the query Jim posted? It is T-SQL syntax and therefore must be run as a pass-through query in Access. If you want something in Access syntax, then the following should do it.
SELECT dbo_EMP_Train.EmpID, IIf(Sum(IIf(IsDate(dbo_Emp
FROM
((dbo_EMP_Train INNER JOIN dbo_JobGroup ON dbo_EMP_Train.PrimaryPosit
INNER JOIN dbo_TrainingCourse ON dbo_JobGroup.CourseID = dbo_TrainingCourse.CourseI
INNER JOIN dbo_Emp_course ON dbo_TrainingCourse.CourseN
Group by dbo_EMP_Train.EmpID;
You'll probably want the employee name in addition to the EmpID but you CANNOT add the course names since that would remove the aggregation.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
THanks
Open in new window
btw I have an article out there on SQL Server CASE Solutions, with a wompload of examples, if it helps.