• Luis Cazares - Wednesday, February 14, 2018 1:55 PM

    Don't aggregate the values on your Widget table, just group by them.

    SELECT W.ID,
       W.Group,
       SUM( WD.Payment) AS Payment,
       W.Invoice
    FROM Widget W
    JOIN WidgetDetail WD ON W.ID = WD.ID
    GROUP BY W.ID, W.Group, W.Invoice;

    Another option is to use MAX or MIN instead of SUM.

    SELECT W.ID, 
       MAX(W.[Group]) AS [Group], 
       SUM( WD.Payment) AS Payment,
       MAX(W.Invoice) AS Invoice
    FROM Widget W 
    JOIN WidgetDetail WD ON W.ID = WD.ID
    GROUP BY W.ID

    Also, you shouldn't use reserved keywords as column names, but if you do, you should at least quote them.  

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA