Aggregate function with DATE TYPE column

  • Hi,

    I need to get monthly count of number of tickets closed. Is it possible to use COUNT() with DATETYPE field?

    SELECT

    ID,

    Environment

    ,count((RT.[type])) As 'Type'

    ,convert(varchar(5),SD.StartDate,110) AS [Month]

    FROM TABLENAME

    GROUP BY Date, Type

    Thanks

  • It should be, but why count(<column name>) rather than Count(*)?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • sql_ques (1/20/2014)


    Hi,

    I need to get monthly count of number of tickets closed. Is it possible to use COUNT() with DATETYPE field?

    SELECT

    ID,

    Environment

    ,count((RT.[type])) As 'Type'

    ,convert(varchar(5),SD.StartDate,110) AS [Month]

    FROM TABLENAME

    GROUP BY Date, Type

    Thanks

    You must put ID and Environment in the GROUP BY clause.

    Regards,

    IgorMi

    Igor Micev,
    My blog: www.igormicev.com

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply