I'm relatively new to Postgresql and SQL in general. I've been sitting on this problem for some time and can't figure out how to write the query to get the result I want.
I have this example table
| User | Name | Paid |
|---|---|---|
| A | aaa | true |
| B | bbb | true |
| C | ccc | false |
| D | aaa | false |
| E | eee | false |
If I execute the query select * from table where Paid is false then I will get
| User | Name | Paid |
|---|---|---|
| C | ccc | false |
| D | aaa | false |
| E | eee | false |
From this table, I want to exlude all users who have the same Name as users in the Paid=true set. So in the end I want to have this result
| User | Name | Paid |
|---|---|---|
| C | ccc | false |
| E | eee | false |
SO basically I want to get all users who have not paid Paid = false and on top of that, exclude all users with the same names as the users who have paid Paid = true.
How do I do this in one query? Thank you in advance.