how to count data

  • hi,

    i have a problem.my data is like that

    CODE------Name

    ACT----------1

    ACT----------1

    ACT----------1

    ACT----------1

    i want data like this.

    CODE------Name

    ACT----------4

    please help me out

    thanks for the help

    immad

  • The same way as in this thread of yours http://www.sqlservercentral.com/Forums/Topic1646925-149-1.aspx, you can just omit the LEFT function since you're grouping by the entire column

    Please don't post multiple threads for the same problem.

    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
  • SELECT CODE, COUNT(Name) AS Name

    FROM TABLENAME

    GROUP BY CODE

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

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