mardi 25 août 2015

count hours in same column

i'm trying to query a table that contains employee records of presence. It records the employee id and datetime of the chipping as follows:

id  datetime
3   2015-07-01 06:58:00.000
3   2015-07-01 12:01:00.000
3   2015-07-01 12:57:00.000
3   2015-07-01 19:17:00.000
3   2015-07-02 06:55:00.000
3   2015-07-02 14:05:00.000
15  2015-07-01 07:50:00.000
15  2015-07-01 12:01:00.000
15  2015-07-01 12:50:00.000
15  2015-07-01 18:04:00.000

i was trying to produce a query that gets

id date       entrance   exit   2entrance   2exit
3  2015-07-01 06:58      12:01  12:57       19:17
3  2015-07-02 06:55      14:05  00:00       00:00
15 2015-07-01 07:50      12:01  12:50       18:04

but the final result i'm looking is

id d1, d2, d3.. d31
3  11  7   12   6
15 9   0   6    12

(this is the number of worked hours, day by day, for a full month)

to get this table i was thinking to use excel with previous results, but i'd apreciate if someone pointed me in the right direction.

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire