• sunder.mekala (2/20/2013)


    Hi All,

    I am trying to write a sql to find the minimum of a dataset

    i am using sql server.

    select ST.BG_DTTM

    ,MIN(ST.BG_DTTM) over(ORDER BY ST.BG_DTTM) AS "Minim"

    from

    tablename ST

    but it is giving me a error saying

    Error: Incorrect syntax near 'order'. (State:37000, Native Code: 66)

    any help is appreciated.

    Thanks,

    Sam.

    I think you need PARTITION BY rather than ORDER BY when using an aggregate with the OVER() clause.