I am trying to write a statement for counting the employees attendance and execute their id
, name
and the days that he has working on the last 3 months by counting the duplicate id
on NewTimeAttendance
for month 1, 2 and 3.
I tried to count:
Select COUNT(employeeid)
from NewTimeAttendance
where employeeid=1 and (month=1 or month = 2 or month = 3)
This is absolutely working, but just for one employee.
The second try:
SELECT COUNT(NewEmployee.EmployeeID)
FROM NewEmployee INNER JOIN NewTimeAttendance
ON NewEmployee.EmployeeID = NewTimeAttendance.EmployeeID
and (month=1 or month =2 or month = 3)
This is working, but it counts all employees and I want it to execute each EmployeeId
, EmployeeName
and number of days
as new record.
Last try: (before you see the code ... it is wrong ..but I am trying)
for i in 0..27 loop
SELECT COUNT(NewEmployee.EmployeeID),NewEmployee.EmployeeId,EmployeeName
FROM NewEmployee INNER JOIN NewTimeAttendance
ON NewEmployee.EmployeeID(i) = NewTimeAttendance.EmployeeID
and (month=1 or month =2 or month = 3)
end loop
I really need help...thanks in advance.