MS SQL how to have values from two row in one?

How to can I get values from two rows into one? Like I have the following raw data

enter image description here

and I want to transform it to: enter image description here

is this even possible with MS SQL?

these are excel sheets but I have the real data on the SQL Server

Explanation: For each product_group_id I want to have the changes of discount_id and the discount_id should have the from_discount_id and to_discount_id ,

for each product_group_id there is a min row of two and for the last entry of product_group_id there should be no entry in the new table as now changes occur.



Read more here: https://stackoverflow.com/questions/66275167/ms-sql-how-to-have-values-from-two-row-in-one

Content Attribution

This content was originally published by TheDev at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: