From 72cec3accf6065d4e6b8a2248a14c5c3697658c0 Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Mon, 17 Jul 2023 15:40:27 -0400 Subject: [PATCH] another script for civi contacts (board forum) --- board-forum-contacts-on-join.sql | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 board-forum-contacts-on-join.sql diff --git a/board-forum-contacts-on-join.sql b/board-forum-contacts-on-join.sql new file mode 100644 index 0000000..c71dc2f --- /dev/null +++ b/board-forum-contacts-on-join.sql @@ -0,0 +1,29 @@ + +-- SPDX-FileCopyrightText: 2023 Andrew Engelbrecht +-- +-- SPDX-License-Identifier: GPL-3.0-or-later + +select c.id from civicrm_contact c +where c.is_deleted = 0 +and c.id not in ( + select contact_id from civicrm_group_contact + where id = 1978 and status = 'Added' -- adhoc exclusion group +) and ( + c.id not in ( + select contact_id from civicrm_membership + where status_id in (1, 2, 3) -- is a member: new, current or grace + ) and ( + c.id in ( + select contact_id from civicrm_membership + where status_id in (1, 2, 3, 4) and end_date >= '2018-01-19' and join_date <= '2022-10-19' -- was a member during time period + ) or c.id in ( + select contact_id from civicrm_contribution + where contribution_status_id = 1 and receive_date >= '2018-01-19' and receive_date <= '2022-10-19' + group by contact_id + having sum(total_amount) >= '120.00' -- donated $120 or more during time period + ) + ) +) order by id asc +into outfile '/var/lib/mysql-files/board-forum-contacts-on-join2.csv' fields terminated by ',' +; + -- 2.25.1