Updating a table with only one occurence of row from another table

  • I need to perform weekly updates of Table B. The data is derived from a table linked to an excel spreadsheet A. There may be several rows in this table which contain duplicated id's. What I need to do is take just one occurrence of the id but sum the line amount as follows:-

    A                                                                   B

    Unique ID   Line Amount                                     Unique ID   Line Amount

    123           800                                                  123           1400

    123           200

    123           400

    How do I best achieve this?

     

  • SELECT
       DISTINCT [Unique ID],
       SUM([Line Amount])
    FROM
       <tablename>
    GROUP BY
       [Unique ID]
     
     

    ******************
    Dinakar Nethi
    Life is short. Enjoy it.
    ******************

  • you don't need "distinct"

    SELECT

     [Unique ID],

        SUM([Line Amount])

    FROM

        <tablename>

    GROUP BY

        [Unique ID]


    * Noel

  • Thanks very much - that works fine

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

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