Skrim 11 Posted July 5, 2021 (edited) Database is PostgreSql. In a table I have: Customer Amount 10000 100 10020 110 10150 350 10000 -100 10300 200 I want to retrieve only customers where Amount is 0 (100-100=0), in this case Customer 10000. How can I do this using Sql? Thanks in advance. Ole Edited July 5, 2021 by Skrim Share this post Link to post
Stano 143 Posted July 5, 2021 ...sum(amount)... Group by customer having sum(amount)= 0 1 Share this post Link to post
Skrim 11 Posted July 5, 2021 Thanks Stano Works great 🙂 SELECT customer, SUM(amount) FROM aTable Group by customer having sum(amount)= 0 Regards, Ole Share this post Link to post