I need to pick value from a second row and populate the value in first row. so if I consider first column as n, then datevalue of n+1 would be populated for n in a new column. Below is a sample data, I have multiple datasets similar to this in a tableCREATE TABLE #temp (idnumber bigint, aid uniqueidentifier,cid uniqueidentifier,dtcreate datetime)INSERT INTO #tempSELECT 1000013337,'30DD885F-AF3E-4B5A-801B-E38EF43EEBA8','E2F40991-D86B-4735-96A2-01C77C142C3C','10/8/2014 11:35:56' UNION ALLSELECT 1000013209,'59ECA44D-41A9-4D81-84B9-758DA2B857A8','E2F40991-D86B-4735-96A2-01C77C142C3C','10/8/2014 9:00:48' UNION ALLSELECT 1000013200,'59ECA44D-41A9-4D81-84B9-758DA2B857A8','E2F40991-D86B-4735-96A2-01C77C142C3C','10/8/2014 8:55:16' UNION ALLSELECT 1000013354,'84C602DA-2193-4EAF-BD0C-621E6AF90EB3','E2F40991-D86B-4735-96A2-01C77C142C3C','10/8/2014 12:01:23' UNION ALLSELECT 1000013407,'84C602DA-2193-4EAF-BD0C-621E6AF90EB3','E2F40991-D86B-4735-96A2-01C77C142C3C','10/8/2014 12:37:19' UNION ALLSELECT 1000013350,'84C602DA-2193-4EAF-BD0C-621E6AF90EB3','E2F40991-D86B-4735-96A2-01C77C142C3C','10/8/2014 11:54:21'
I trying to get a select which will return below result.idnumber|aid|cid|dtstart|dtend1000013200|59ECA44D-41A9-4D81-84B9-758DA2B857A8|E2F40991-D86B-4735-96A2-01C77C142C3C|2014-10-08 08:55:16.000|2014-10-08 09:00:48.000
In the above case, dtcreate of n+1 record became the dtend for n record.This is only for 1 cid, there are multiple cid's inbetween these records for ease i just picked up one of them.Any help is appreciated.