stored procedures - How to use row as a column in SQL Server 2014? -


enter image description here

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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -