I have a simple question on a select statement.

  • Here is the query I am using. However the ID is always 1.

    How do I bring back a different ID for each row?

    select @@rowcount ID, EquipmentClass,EquipmentMake,EquipmentYear

    from prdappall

    group by EquipmentClass,EquipmentMake,EquipmentYear

  • Look up the ROW_NUMBER function.

    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
  • May be this would help.

    Select *, row_number() Over (Partition By <field name> Order By <field name>) As RowCount From <table name>

    Vinu Vijayan

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

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

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