How to display rows that when added together equal zero

后端 未结 6 1689
一生所求
一生所求 2021-01-29 01:39

Been searching for a few weeks for a solution to this but have come up blank.

I have table of data similar to this:

client_ref  supplier_key  client_amou         


        
6条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 01:51

    SELECT t.* FROM Table1 AS t INNER JOIN
    (SELECT [client_ref], [supplier_key], SUM([client_amount]) as Total
    FROM Table1 GROUP BY [client_ref], [supplier_key]) AS sumTable
    ON t.[client_ref] = sumTable.[client_ref] AND
    t.[supplier_key] = sumTable.[supplier_key]
    WHERE Total = 0;
    

    SAMPLE FIDDLE

提交回复
热议问题