我只需要计算以下示例查询的用户表结果:
SELECT
count (1) filter (where coalesce( users.membership_1_end > current_timestamp at time zone 'GMT',
users.membership_2_end > current_timestamp at time zone 'GMT',
users.membership_3_end > current_timestamp at time zone 'GMT',
users.membership_4_end > current_timestamp at time zone 'GMT')) as active_subs
from users,invoices
发生这种情况,只有查询中有表用户时,这种计数就可以了,而当发票加到查询中时,返回一个疯狂的值。
如何只过滤用户表中的计数结果?