Thursday, August 29, 2013

SQL Function

Are you looking for the below query,



SELECT FiveMinutes, Avg(Val) as Val FROM (
SELECT
DATEADD(minute,(DATEDIFF(minute,DayStart,[DateTime])/5)*5,DayStart) AS
FiveMinutes, Val FROM (SELECT *,
DATEADD(day,DATEDIFF(day,0,[DateTime]),0) as DayStart
FROM table1) as A
) X
GROUP BY FiveMinutes





Regards, RSingh


No comments:

Post a Comment