How can I use two or more COUNT()s in one SELECT statament?
- by jjj
i develop this code:
SELECT COUNT(NewEmployee.EmployeeID), NewEmployee.EmployeeId,EmployeeName
FROM NewEmployee INNER JOIN NewTimeAttendance
ON NewEmployee.EmployeeID = NewTimeAttendance.EmployeeID
and NewTimeAttendance.TotalTime is null
and (NewTimeAttendance.note = '' or NewTimeAttendance.note is null)
and (month = 1 or month = 2 or month = 3)
GROUP BY NewEmployee.EmployeeID, EmployeeName
order by EmployeeID
from my previous two questions selecting null stuff and counting issue...that amazing code is working beautifully fine..but now i need to select more than one count...
...searched (google) .... found alias...tried:
SELECT COUNT(NewEmployee.EmployeeID) as attenddays, COUNT(NewEmployee.EmployeeID) as empabsent
, NewEmployee.EmployeeId,EmployeeName
FROM NewEmployee INNER JOIN NewTimeAttendance
ON empabsent =NewEmployee.EmployeeID = NewTimeAttendance.EmployeeID
and NewTimeAttendance.TotalTime is null
and (NewTimeAttendance.note = '' or NewTimeAttendance.note is null )
and (month=1 or month =2 or month = 3) ,
attenddays = NewTimeAttendance.EmployeeID
and NewTimeAttendance.TotalTime is null
and (NewTimeAttendance.note = '' or NewTimeAttendance.note is null )
and (month=1 or month =2 or month = 3)
GROUP BY NewEmployee.EmployeeID, EmployeeName order by EmployeeID
Incorrect syntax near '='.
second try:
SELECT COUNT(NewEmployee.EmployeeID) as attenddays, COUNT(NewEmployee.EmployeeID) as absentdays,
NewEmployee.EmployeeId,EmployeeName
FROM NewEmployee INNER JOIN NewTimeAttendance
ON attenddays(NewEmployee.EmployeeID = NewTimeAttendance.EmployeeID
and NewTimeAttendance.TotalTime is null
and (NewTimeAttendance.note = '' or NewTimeAttendance.note is null )
and (month=1 or month =2 or month = 3)) ,
absentdays(NewEmployee.EmployeeID = NewTimeAttendance.EmployeeID
and NewTimeAttendance.TotalTime is null
and (NewTimeAttendance.note = '' or NewTimeAttendance.note is null )
and (month=1 or month =2 or month = 3))
GROUP BY NewEmployee.EmployeeID, EmployeeName order by EmployeeID
Incorrect syntax near '='.
not very good ideas... so ...help
thanks in advance