Home > Software design >  How do I get count of leaves with respect to employee code in SQL?
How do I get count of leaves with respect to employee code in SQL?

Time:03-04

select PER_CODE as [EMP CODE], EXC_DATE as LEAVES
from R5EXCEPTIONS
inner join R5PERSONNEL on PER_CODE = EXC_PERSON

Mention above is my above code. I want to get count of leaves in another column.

Mention below is my code output:

Code Output

CodePudding user response:

You can count the number of leaves by grouping employee code

Select PER_CODE As [EMP CODE] , COUNT(EXC_DATE) as LEAVES from 
R5EXCEPTIONS inner join R5PERSONNEL  on PER_CODE = EXC_PERSON
group by PER_CODE

CodePudding user response:

You can use an aggregate SQL query to get the number of PER_CODE events by date.

The following would represent this:

select count(PER_CODE) as [EMP VOL], EXC_DATE as LEAVES
from R5EXCEPTIONS
inner join R5PERSONNEL on PER_CODE = EXC_PERSON
Group by EXC_DATE
  • Related