stored procedures - How to use row as a column in SQL Server 2014? -
this result want first check in , last check out result want output this
------------------------------------------------------------------------------- attedate | staffname | staffid | shiftname|firmid| checkin |checkout | total duration -------------------------------------------------------------------------------- 2017-03-20|swapnil r gupta |5036 |general | 1 |09:09:41 |21:33:01 |12:24:01
using conditonal aggregation query, grouping date of attenddate
.
select attenddate = convert(date,t.attenddate) , t.staffname , t.staffid , t.shiftname , t.firmid , checkin = min(case when inoutmode = 'checkin' convert(time(0),t.attenddate) end) , checkout = max(case when inoutmode = 'checkout' convert(time(0),t.attenddate) end) t group t.staffname , t.staffid , t.shiftname , t.firmid , convert(date,t.attenddate)
Comments
Post a Comment