my current code is update #temptable set startdate = (select min(date) from #temptable tt where tt.name=t.name),enddate = (select max(date) from #temptable tt ,where tt.name=t.name)from #temptable tdelete #temptable where id not in (select max(convert(nvarchar(100),id)) from #temptable group by
what this does is for each name if takes the min and max record and updates start date and end date and then leaves me with just one record - I need to change this instead to order by date and then take for every 2 records -- the first one becomes startdate second enddate (and just save it as 1 record for each 2 with the duration the time between startdate and enddate)can someone help me with the sql for this please?