Reputation: 867
In my SQL database table i have record like
EmpID(int-pk) | Attend-Date(datetime) |workinghrs(time(0))|extrahrs(time(0))
-----------------------------------------------------------------------------
1 | 15-04-2015 | 04:10:30 |01:00:00
1 | 16-04-2015 | 02:10:30 |02:00:00
1 | 17-04-2015 | 04:50:30 |04:00:00
2 | 18-04-2015 | 01:40:00 |01:40:00
2 | 14-04-2015 | 06:10:00 |00:40:00
Now i need to select this record between date range from 14-04-2015 to 18-04-2015 but with sum of workinghrs and extrahrs against each EmpID
something like this
EmpID(int-pk) | |workinghrs (time(0)) |extrahrs(time(0))
------------------------------------------------------
1 |11:20:30 |07:00:00
2 |07:50:00 |02:20:00
Then i have to show all this on crystal report. I am using c# windows app and on this issue i have no idea how to build a logic. Thanks in advance.
Upvotes: 1
Views: 195
Reputation: 1730
You mean the logic of query? If yes this will give the result
select EmpID ,sum(DATEDIFF(MINUTE, '0:00:00', workinghrs ))
,sum(DATEDIFF(MINUTE, '0:00:00', extrahrs ))
from <table>
group by EmpID
Order by EmpId
Upvotes: 1