Jump to content
Sign in to follow this  
Skrim

Help with Sql

Recommended Posts

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 by Skrim

Share this post


Link to post

...sum(amount)...

Group by customer

having sum(amount)= 0

  • Like 1

Share this post


Link to post

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×