Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Merge Clock-In and Clock-out Row Into One Row

$
0
0

I have one table that captures the time (among other data) of every clock entry and sets a field (Type) to 1 for clock-in and 2 for clock-out. I would like to merge one pair of In/Out times into a single row. There may be more than one pair for an employee for a given day.

Clock Entries

EENumber Name ClockTime Job JobID Type
15989 First Last 2019-05-01 03:46:20.000 7E 105 1
15989 First Last 2019-05-01 03:46:46.000 7E 105 2
15989 First Last 2019-05-01 03:46:47.000 7E 105 1
15989 First Last 2019-05-01 13:20:49.000 7E 105 2

Desired Result

EENumber Name ClockIn ClockOut Job JobID
15989 First Last 2019-05-01 03:46:20.000 2019-05-01 03:46:46.000 7E 105
15989 First Last 2019-05-01 03:46:47.000 2019-05-01 13:20:49.000 7E ...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>