From fedc51514dafb818a333e70e17e54307be8a7cf3 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 2 Aug 2024 00:03:22 +0530 Subject: [PATCH] Fix incorrect count in subscriber query when there are no results. --- queries.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.sql b/queries.sql index 23cd3d28..9bed63ec 100644 --- a/queries.sql +++ b/queries.sql @@ -326,7 +326,7 @@ SELECT COUNT(*) AS total FROM subscribers -- name: query-subscribers-count-all -- Cached query for getting the "all" subscriber count without arbitrary conditions. -SELECT SUM(subscriber_count) AS total FROM mat_list_subscriber_stats +SELECT COALESCE(SUM(subscriber_count), 0) AS total FROM mat_list_subscriber_stats WHERE list_id = ANY(CASE WHEN CARDINALITY($1::INT[]) > 0 THEN $1 ELSE '{0}' END) AND ($2 = '' OR status = $2::subscription_status);