Postgresql 在另一列中选择具有不同赋值的对象
简化了我在这个表中的问题,我想在PostgreSQL中只选择已经付款的人,我有另外一个已经付款和没有付款的人,我想排除这些人,谢谢Postgresql 在另一列中选择具有不同赋值的对象,postgresql,select,Postgresql,Select,简化了我在这个表中的问题,我想在PostgreSQL中只选择已经付款的人,我有另外一个已经付款和没有付款的人,我想排除这些人,谢谢 People Payment Debt/n John Pay $100 John Paid $200 Luis Paid $150 Luis Paid $300 您可以在此处使用条件聚合: SELECT People FROM yourTable GROUP BY People HAVING COUNT(*) FIL
People Payment Debt/n
John Pay $100
John Paid $200
Luis Paid $150
Luis Paid $300
您可以在此处使用条件聚合:
SELECT People
FROM yourTable
GROUP BY People
HAVING COUNT(*) FILTER(WHERE Payment = 'Pay') = 0;
这可能是另一种选择,假设您的表名为“people\u payments”
在这种情况下,结果应该是什么?
Select People from people_payments
where Payment='Paid'
and People NOT IN (Select People from people_payments where Payment='Pay') ;