-1

I have a database where I have multiple timestamp of each employ for each day.I want to calculate working hours from min and max timestamp of EACH DAY of the MONTH.

Something like this:

idx=primary key 
idx  id          date
1   8080   2018-09-25 12:16:12
2   8081   2018-09-25 12:42:06
3   8080   2018-09-25 13:16:12
4   8080   2018-09-25 15:11:11
5   8081   2018-09-25 16:16:33
6   8080   2018-09-26 11:15:12
7   8081   2018-09-26 12:11:12
8   8080   2018-09-26 17:16:12
9   8081   2018-09-26 18:16:12


Desired o/p
id      date        MIN(date)-MAX(date) workhours(in hours)
8080   2018-09-25            04
8081   2018-09-25           3:34
8080   2018-09-26           6:01
8081   2018-09-26           6:05
Strawberry
  • 33,750
  • 13
  • 40
  • 57
  • See: [Why should I provide an MCVE for what seems to me to be a very simple SQL query?](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query) – Strawberry Sep 27 '18 at 13:22

1 Answers1

0

Got the solution myself by following query: SELECT id,min(date),max(date), TIMEDIFF(max(date), min(date))As Diff_Value FROM attendance GROUP BY DATE(date),id ;