• mike.jones 60369 (9/23/2016)


    Hi I am new to this application and my question I believe is rather basic, so forgive me.

    I have two tables A and B below and I wish to get the following

    Order No Qty

    1 6

    2 8

    Table A has order nos and other info

    Order No

    1

    2

    3

    ..

    Table B has order no and quantity and other info

    order qty

    1 1

    1 2

    1 3

    2 4

    2 1

    The data in your tables doesn't support the desired output... 4+1=5 not 8...

    Also... Base on the sample data, the desired output does not require table A to be involved at all...

    SELECT

    b.Order

    Qty = SUM(b.qty)

    FROM

    dbo.TableB b

    GROUP BY

    b.Order

    ORDER BY

    b.Order