You can use the F_START_OF_MINUTE function in this link to get the start of each minute to group by.Start of Time Period Functionshttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64755You can get the start and end prices with a self join on the min and max time within each one minute period.select a.DateStampMinute, a.MaxPrice, a.MinPrice, StartPrice = b.Price EndPrice = c.Pricefrom ( select DateStampMinute = dbo.F_START_OF_MINUTE(aa.DateStamp ), MaxPrice = max(aa.,Price), MinPrice = min(aa.Price), MaxDateStamp = max(aa.DateStamp), MinDateStamp = min(aa.DateStamp) from MasterData aa group by dbo.F_START_OF_MINUTE( aa.DateStamp ) ) a join MasterData b on a.MaxDateStamp = b.DateStamp join MasterData c on a.MaxDateStamp = c.DateStamporder by a.DateStampMinute
CODO ERGO SUM