question

kwacz23 avatar image
kwacz23 asked

transform data rows into data ranges

Hello, I have employee data in the attached table 1![alt text][1] I would like to have final out like like in the attached table2 ![alt text][2] This is one example in the file a have multiple lines. Initial input can have more than 2 lines for each employee but convert logic will be the same. Thank you for help! [1]: /storage/temp/3492-table1.png [2]: /storage/temp/3493-table2.png
tsql
table1.png (3.3 KiB)
table2.png (3.5 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Wimbush avatar image
David Wimbush answered
If you're on SQL 2012 or later you can use the LEAD() function to get at the date from the following line.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kwacz23 avatar image
kwacz23 answered
Thank you for answer I have managed to do that via LEAD and LAG functions.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.