i need to ask a couple of questions to clarify:
1. you mention you need to get row 2 from ID 1 and row 1 from ID 2. what is the order of the data supposed to be? will the AvgTime column being ascending? because if there is no ordering specified (either by a clustered index or an order by clause) you can't guarantee that the second row you want is the second row you get
2. ID 3 row 1: in your final output you have the AvgTime of device D1 as 230, but in the source table the first row has a value of 200. Which is correct?
3. Do you know the number of devices before hand? Is this number fixed?
After looking at this again, an SSIS package maybe over-egging the pudding. It could be possible to do this with plain T-SQL after all. Would this run on a SQL2005 box?
Tom