Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My Table: (For Current Month)
EMPCODE DATE ATTENDANCEMODE
100 01/01/2020 A
100 02/01/2020 A
100 03/01/2020 A
101 03/01/2020 A
102 02/01/2020 A
102 03/01/2020 A

What i need?

EMPCODE CONTINUOUSLEAVEFORHOWMUCHDAYS:
100 3
101 1
102 2

Note: 03/01/2020 is the current date

What I have tried:

select COUNT(*) from mytable where date='2020/01/03'
Posted
Updated 20-Feb-20 5:15am
v2
Comments
[no name] 20-Feb-20 10:36am    
You need the "days present" too, if you don't want to go crazy.

1 solution

select code EMPCODE,count(date) as 'CONTINUOUSLEAVEFORHOWMUCHDAYS' from employee
where date = '01/02/2020'
group by Code

Accept solution if you are happy with the solution 
 
Share this answer
 
v3
Comments
MadMyche 20-Feb-20 12:29pm    
Did you run this against the data given AND get the desired result set?
RAHUL(10217975) 22-Feb-20 7:08am    
Yes. Query is working fine against the data given and got desired result set
Sissy Ram 14-Mar-20 4:13am    
@Rahul(10217975) Do you think this is right query

IF
My Table: (For Current Month)
EMPCODE DATE ATTENDANCEMODE
100 01/01/2020 P
100 02/01/2020 A
100 03/01/2020 A
100 04/01/2020 P
100 05/01/2020 A
100 06/01/2020 A
100 07/01/2020 A
Current date 07-01-2020

What I need?
EMPCODE CONTINUOUSLEAVEFORHOWMUCHDAYS:
100 3

Will the above query works for this?
NO..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900