counting employee attendance

Posted by jjj on Stack Overflow See other posts from Stack Overflow or by jjj
Published on 2010-03-15T12:26:40Z Indexed on 2010/03/15 12:29 UTC
Read the original article Hit count: 180

Filed under:
|

i am trying to write a statment for counting the employees attendance and execute thier 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 secound 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 realy need help...thanks in advance

© Stack Overflow or respective owner

Related posts about sql

Related posts about count