• the way you did it is grouping by minute ( not taking year/month/day/hour into account )

    This is how I would do it.

    SELECT

    datepart(mi,[startDate]) as MI,

    min(startDate) as startDate,

    avg(duration) Duration

    FROM Logs with (nolock)

    WHERE Id IN ( 'HI' )

    /* avoid using BETWEEN with datetime datatype */

    AND startdate >='2013-06-17 08:30:00.000' AND startdate < '2013-06-17 10:00:00.000'

    AND sourcemodule = 'panel'

    group by datepart(mi,[startDate])

    order by startdate

    it depends on the simantics of what you need.

    SELECT

    dateadd(mi, datediff(mi,[startDate], 0),0) as MI,

    min(startDate) as startDate,

    avg(duration) Duration

    FROM Logs with (nolock)

    WHERE Id IN ( 'HI' )

    /* avoid using BETWEEN with datetime datatype */

    AND startdate >='2013-06-17 08:30:00.000' AND startdate < '2013-06-17 10:00:00.000'

    AND sourcemodule = 'panel'

    group by dateadd(mi, datediff(mi,[startDate], 0),0) --convert to datetime minute level

    order by startdate

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me